Compare commits

..

81 Commits

Author SHA1 Message Date
cc74083ef2 chore: release x6@2.12.1 2023-07-05 10:13:58 +08:00
fb10ef0879 fix: render edge when source or target in render area (#3730) 2023-07-05 09:51:06 +08:00
543de1999d chore: release some packages (#3727) 2023-07-03 20:39:37 +08:00
37e8c2242c fix: set some function to own attrs (#3726)
* fix: set some function to own attrs

* chore: change dnd to deps for stencil plugin
2023-07-03 19:48:58 +08:00
78f05b6287 chore: update CONTRIBUTORS [skip ci] 2023-07-02 00:25:03 +00:00
6037fdeb10 chore: update contributors [skip ci] 2023-07-02 00:17:33 +00:00
8835ee6a56 docs: Add notes in the scroller plugin doc (#3722) 2023-07-02 08:17:12 +08:00
db6f49d65a chore: update CONTRIBUTORS [skip ci] 2023-06-28 10:28:36 +00:00
01e911b5f8 chore: update contributors [skip ci] 2023-06-28 10:20:51 +00:00
377af16922 docs: fix port-layout zh doc typos (#3717) 2023-06-28 18:20:28 +08:00
ef5388ed4a docs: optimize docs (#3703)
* docs: optimize connector docs

* docs: optimize docs for node-anchor

* docs: add demo for edge anchor

* docs: add demo for connection point

* docs: add demo for attrs

* docs: add demos for filter

* docs: add demos for port layout

* docs: add demos for port label layout
2023-06-26 19:39:35 +08:00
6e8422ebd2 docs: optimize docs for mvc (#3701) 2023-06-22 23:08:04 +08:00
8f136d12db docs: update marker.md (#3696) 2023-06-19 21:13:00 +08:00
38d28c0626 docs: add demos for label doc (#3690) 2023-06-19 09:58:27 +08:00
7716765910 chore: update CONTRIBUTORS [skip ci] 2023-06-17 14:56:59 +00:00
2a05b02c4f chore: format scripts (#3689) 2023-06-17 22:49:36 +08:00
7a5019028d chore: prettierrc all files (#3688)
* chore: update bug report template

* chore: update username in commit whitelist

* chore: update basic demo

* chore: prettier all files

* chore: update link in readme
2023-06-17 22:43:24 +08:00
a3fef50df3 chore: update contributors [skip ci] 2023-06-17 14:37:12 +00:00
e08c3a9bd7 fix(Group): add Condition:Embeds the edge if source and target are not same (#3659)
Co-authored-by: 朱泽宇 <zhuzy@digiwin.com>
2023-06-17 22:36:51 +08:00
ebee229402 fix: reset factor when calc factor is 1 (#3658) 2023-06-07 17:24:41 +08:00
51a512ae67 chore: update CONTRIBUTORS [skip ci] 2023-06-06 11:35:17 +00:00
82e0aefc21 chore: update contributors [skip ci] 2023-06-06 11:28:22 +00:00
4cb3bea6b7 docs: optimize docs for model (#3653) 2023-06-06 19:26:54 +08:00
101e3f96b6 chore: update CONTRIBUTORS [skip ci] 2023-06-06 08:54:08 +00:00
8c233a9419 chore: update CONTRIBUTORS [skip ci] 2023-06-06 08:53:41 +00:00
2421fa3513 docs: typo fix (#3648) 2023-06-06 16:46:53 +08:00
9684766150 fix($stencil): compact mode Cannot add odd nodes (#3647)
fix($stencil): compact mode Cannot add odd nodes in mode

Add null check when node getSize()
add check valid node in function getNodesInRow/Column

Closes #3535

Co-authored-by: 朱泽宇 <zhuzy@digiwin.com>
2023-06-06 16:45:54 +08:00
075f54059e fix: replace children prop to childNodes (#3645) 2023-06-06 16:22:55 +08:00
1eccc05f76 chore: update contributors [skip ci] 2023-05-30 01:28:49 +00:00
86b5a23630 chore: update CONTRIBUTORS [skip ci] 2023-05-29 12:43:56 +00:00
161e702916 Update .dumirc.ts 统一官网消息配置,合并后官网发个版 (#3625)
Update .dumirc.ts

统一官网消息配置,合并后官网发个版
2023-05-29 20:36:26 +08:00
9a8fa8a925 fix: widget ouside graph, close #3595 (#3597) 2023-05-19 22:48:30 +08:00
0da7693f5b chore: release x6@2.11.1 and x6-react-shape@2.2.2 (#3600) 2023-05-19 22:35:05 +08:00
b92976a278 docs: optimize cell.md (#3599) 2023-05-18 19:38:10 +08:00
1d64938758 chore: update contributors [skip ci] 2023-05-16 14:26:57 +00:00
876e8b91bb fix: same cell id when using portal #2949 (#3591)
* fix: save cell id when using portal #2949

* fix: same cell id when using portal #2949
2023-05-16 22:26:31 +08:00
01bb8105c9 fix: setText and getText support string (#3586) 2023-05-15 09:56:51 +08:00
6273fd55ac devtool docs (#3585)
* chore: update x6-dev-tool readme

* chore: update docs, add devtool

* chore: revert pnpm-lock
2023-05-13 12:03:30 +08:00
5010a94d14 docs: optimize doc for cell (#3580) 2023-05-11 10:05:56 +08:00
aa65bfaa88 fix: trigger dblclick event only one time (#3577) 2023-05-09 16:36:45 +08:00
148d7d72bc chore: update CONTRIBUTORS [skip ci] 2023-05-08 06:22:44 +00:00
0b1a298cb9 chore: update contributors [skip ci] 2023-05-08 06:15:08 +00:00
35aa68ba6f fix: undo crash when attr is null (#3569) 2023-05-08 14:14:43 +08:00
18f6d9bae3 docs: optimize docs for coordinate (#3553) 2023-04-28 17:45:44 +08:00
0bd4429fb3 feat: change manifest for submit to chrome web store (#3552) 2023-04-28 17:45:36 +08:00
7d33889855 docs: optimize docs for panning (#3543) 2023-04-26 15:23:55 +08:00
c5b80402dd docs: optimize grid and background docs (#3536) 2023-04-24 20:14:44 +08:00
9495b4c90d chore: update contributors [skip ci] 2023-04-20 14:15:54 +00:00
e0719054b5 fix: reset undefined attrs when undo (#3526)
* docs: add sitemap for websites

* fix: reset undefined attrs when undo

* docs: update sitemap
2023-04-20 22:15:29 +08:00
c08d2ceb50 chore: update CONTRIBUTORS [skip ci] 2023-04-20 08:16:35 +00:00
7f8fb69e21 chore: update contributors [skip ci] 2023-04-20 08:10:39 +00:00
8ff81807a7 docs: fix marker link that now target correct page (#3523)
docs: fix link that now target correct page
2023-04-20 16:10:14 +08:00
ec5c67d84c docs: Update marker.zh.md (#3524)
Util.normalizeMarker -> Registry.Marker.normalize

refer to ea01b1d3eb/packages/x6/src/registry/marker/util.ts (L7)
2023-04-20 16:09:49 +08:00
ea01b1d3eb chore: release x6@2.9.7 and selection@2.1.7 (#3505) 2023-04-13 23:44:54 +08:00
0b1e0c754b fix: remove editor before added (#3504) 2023-04-13 23:39:58 +08:00
071ef37569 chore: update CONTRIBUTORS [skip ci] 2023-04-13 14:44:16 +00:00
8b4602b980 chore: update contributors [skip ci] 2023-04-13 14:36:03 +00:00
cd1ee4a77c docs: careless mistake fix of docs (#3503)
careless mistake fix
2023-04-13 22:35:33 +08:00
242316b459 chore: release some packages (#3499) 2023-04-13 10:22:21 +08:00
2a35be764b docs: restricted => restrict (#3495) 2023-04-12 16:17:49 +08:00
f437269e6f chore: cancel useless options (#3489) 2023-04-11 17:45:44 +08:00
7f300fe551 docs: optimize router docs (#3484)
* docs: optimize router docs

* docs: change style of code
2023-04-10 19:38:34 +08:00
73dbd1ef58 chore: release x6@2.9.5 (#3482)
* chore: remove changeset

* chore: release x6@2.9.5
2023-04-10 15:32:03 +08:00
ffa0431e35 fix: mock mouseenter and mouseleave event (#3481)
* fix: mock mouseenter and mouseleave events for port

* chore: add publish packages script

* chore: update ui.js for devtool
2023-04-10 15:07:11 +08:00
f8490a029d chore: update contributors [skip ci] 2023-04-05 01:23:06 +00:00
b56fc2c3eb docs: unified doc format (#3469) 2023-04-05 03:21:19 +08:00
f3ef783b7d chore: update CONTRIBUTORS [skip ci] 2023-04-03 14:18:50 +00:00
7d458bff3b chore: update contributors [skip ci] 2023-04-03 14:10:38 +00:00
89d5465db0 docs: fix NodeAnchor doc wrong (#3464)
docs: 修复 NodeAnchor 文档错误
2023-04-03 22:10:01 +08:00
5edfc8885e fix: remove unused type (#3457) 2023-04-01 08:55:37 +08:00
ba370df246 fix: remove connection strategy option (#3456) 2023-04-01 08:51:11 +08:00
506ab14595 fix: fix error usage of parseInt (#3455) 2023-03-31 22:26:37 +08:00
837bbee715 chore: update contributors [skip ci] 2023-03-31 13:45:18 +00:00
b2e1315f79 feat: support render simple view in minimap (#3453)
* fix: chagne model writable

* fix: auto construct view after createView hook

* fix: chagne createCellView return type

* fix: render existed cells when init

* fix: reset model when dispose minimap

* docs: add simple mode for minimap demo

* chore: release x62.9.2 and minimap@2.0.4
2023-03-31 21:44:53 +08:00
6c76deefd2 chore: update CONTRIBUTORS [skip ci] 2023-03-31 06:35:29 +00:00
9fa0f844c7 fix: type of moveThreshold should be number (#3450) 2023-03-31 14:28:54 +08:00
fa69ddbe68 chore: release @antv/x6@2.9.1 (#3448) 2023-03-30 19:35:06 +08:00
fb3535dc75 feat: support closest connection strategy (#3447)
* feat: support snap in edgeview

* feat: add connectNodeStrategy and connectEdgeStrategy option

* fix: change type for allowBlank

* fix: change type of geConnectionTerminalAnchor

* docs: add docs for connection strategy
2023-03-30 19:31:13 +08:00
20da5acb37 chore: update docsearch api key (#3438)
* chore: update docsearch api key

* docs: update dingding qcode
2023-03-29 11:13:32 +08:00
595f60597c docs: optimze docs for tools (#3431)
* chore: change workspace deps for example

* fix: change allowBlank default value

* refactor: refactor editor tool

* fix: change the condition of render tools

* chore: release x6@2.8.0

* docs: optimze docs for tools
2023-03-26 09:57:36 +08:00
9e759518c8 chore: release 2 packages (#3428) 2023-03-24 17:41:42 +08:00
392 changed files with 20726 additions and 7899 deletions

View File

@ -75,7 +75,7 @@ body:
value: |
- OS: [e.g. macOS, Windows, Linux]
- Browser: [e.g. Chrome, Safari, Firefox]
- Version: [e.g. 91.1]
- Version: [e.g. 2.11.1]
validations:
required: true
- type: textarea

View File

@ -51,8 +51,8 @@ body:
label: 平台
value: |
- 操作系统: [macOS, Windows, Linux, React Native ...]
- 网页浏览器: [Google Chrome, Safari, Firefox]
- X6 版本: [1.28.2 ... ]
- 网页浏览器: [Google Chrome, Safari, Firefox ...]
- X6 版本: [2.11.1 ...]
validations:
required: true
- type: textarea

View File

@ -35,4 +35,4 @@
- [ ] I have updated the documentation accordingly.
- [ ] I have read the [**CONTRIBUTING**](https://github.com/antvis/x6/blob/master/CONTRIBUTING.md) document.
- [ ] I have added tests to cover my changes.
- [ ] All new and existing tests passed.
- [ ] All new and existing tests passed.

View File

@ -3,7 +3,7 @@
branch="$(git rev-parse --abbrev-ref HEAD)"
user="$(git config user.name)"
whitelist=("bubkoo" "NewByVector")
whitelist=("bubkoo" "newbyvector")
if [[ ! " ${whitelist[@]} " =~ " ${user} " ]]; then
if [ "$branch" = "master" ]; then

View File

@ -1,9 +1,9 @@
*.md
*.sh
*.yml
*.svg
*.gif
*.log
*.md
.DS_Store
CNAME
AUTHORS
@ -11,6 +11,8 @@ LICENSE
es/
lib/
dist/
public/
.dumi/
coverage/
sites/public
csstype.ts

View File

@ -2,75 +2,46 @@
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, sex characteristics, gender identity and expression,
level of experience, education, socio-economic status, nationality, personal
appearance, race, religion, or sexual identity and orientation.
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others' private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at antv@antfin.com. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at antv@antfin.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see
https://www.contributor-covenant.org/faq
For answers to common questions about this code of conduct, see https://www.contributor-covenant.org/faq

View File

@ -1,7 +1,6 @@
# Contribution Guide
If you have any comment or advice, please report your [issue](https://github.com/antvis/x6/issues),
or make any change as you wish and submit a [PR](https://github.com/antvis/x6/pulls).
If you have any comment or advice, please report your [issue](https://github.com/antvis/x6/issues), or make any change as you wish and submit a [PR](https://github.com/antvis/x6/pulls).
## Reporting New Issues

View File

@ -45,8 +45,7 @@ $ git push origin branch-name
### Commit 提交规范
根据 [angular 规范](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit-message-format)提交 commit
这样 history 看起来更加清晰,还可以自动生成 changelog。
根据 [angular 规范](https://github.com/angular/angular.js/blob/master/CONTRIBUTING.md#commit-message-format)提交 commit这样 history 看起来更加清晰,还可以自动生成 changelog。
```xml
<type>(<scope>): <subject>
@ -121,7 +120,7 @@ X6 基于 [semver](http://semver.org/lang/zh-CN/) 语义化版本号进行发布
### 发布策略
在每个大版本的发布中都会有一个PM他在发布的不同阶段负有以下职责
在每个大版本的发布中,都会有一个 PM他在发布的不同阶段负有以下职责
#### 准备工作:

View File

@ -1,4 +1,7 @@
91jojo <jstxhl@live.com>
@thinkinggis <lzx199065@gmail.com>
BARM <284942955@qq.com>
CJrZhang <39872522+CJrZhang@users.noreply.github.com>
Candy <563378816@qq.com>
Chaoqi ZHANG <prncoprs@163.com>
Clifford Fajardo <cliffordfajardo@users.noreply.github.com>
@ -11,6 +14,7 @@ Gossypol <31892817+gossypol@users.noreply.github.com>
HQidea <HQidea@users.noreply.github.com>
ImgBotApp <ImgBotHelp@gmail.com>
Indomi <indomi126@gmail.com>
JackyChen02 <70377567+JackyChen02@users.noreply.github.com>
James Tsang <wtzeng1@gmail.com>
JasonSun <42314340+LolipopJ@users.noreply.github.com>
Jinxing Lin <172601673@qq.com>
@ -27,6 +31,7 @@ Mingfei <az8641683@163.com>
MrMengJ <2646973632@qq.com>
Naveen <172697+naveensrinivasan@users.noreply.github.com>
NewByVector <NewByVector@users.noreply.github.com>
OZiyuTao <127707782+OZiyuTao@users.noreply.github.com>
Olive.Wang <olivewind.wang@gmail.com>
Opportunity <opportunity@live.in>
Questions <chip@twostewards.com>
@ -35,17 +40,18 @@ SSC <273702440@qq.com>
Samuel Bodin <1637651+bodinsamuel@users.noreply.github.com>
Simon He <57086651+Simon-He95@users.noreply.github.com>
Sindori <441933726@qq.com>
Struggle <1178825961@qq.com>
Struggle Roue <47975400+struggleRoue@users.noreply.github.com>
Susan <527971893@qq.com>
Thomas Zeugner <tomsoftware@gmx.de>
Tony Wu <93302820+tonywu6@users.noreply.github.com>
Utopia <greatauk11@gmail.com>
WBbug <1056342711@qq.com>
XLZY <1017866168@qq.com>
Xia Wenqi <xiawenqi90@gmail.com>
Xingjian Zhang <44231913+THUzxj@users.noreply.github.com>
Zhenyu Hou <skyking_H@hotmail.com>
_XiaoTian <istianlei@qq.com>
aimagic <40253639+aimagic@users.noreply.github.com>
arthur657834 <kingkom7834@126.com>
boyu.zlj <boyu.zlj@antgroup.com>
breezefaith <nyzhangzc@qq.com>
@ -91,11 +97,14 @@ x6-bot <x6-bot@users.noreply.github.com>
xrkffgg <xrkffgg@gmail.com>
yaojin2070 <48686959+yaojin2070@users.noreply.github.com>
zdc1111 <39116292+zdc1111@users.noreply.github.com>
zzyyu <33147972+zzyyu@users.noreply.github.com>
€alix <qq287649920@gmail.com>
一纸忘忧 <54543761+ikxin@users.noreply.github.com>
九思⚡⚡⚡ <2228429150@qq.com>
何腾飞 <avrin.live.cn@outlook.com>
依枫 <deng25st@163.com>
偏右 <afc163@gmail.com>
大卫 <36500514+qiufeihong2018@users.noreply.github.com>
小耀 <jinyue.gjy@antfin.com>
崖 <bubkoo.wy@gmail.com>
崖崖崖 <bubkoo.wy@gmail.com>
@ -105,6 +114,7 @@ zdc1111 <39116292+zdc1111@users.noreply.github.com>
杨凌 <89915256@qq.com>
柏愚 <boyu.zlj@antfin.com>
粑粑超 <842486229@qq.com>
練氣士 <62411296+hongfaqiu@users.noreply.github.com>
诸岳 <dengfuping_private@163.com>
金强强 <wenyu.jqq@antfin.com>
问崖 <bubkoo.wy@gmail.com>

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 14 MiB

After

Width:  |  Height:  |  Size: 16 MiB

View File

@ -22,10 +22,10 @@
## Features
- 🌱 Easy-to-customize: based on well known SVG/HTML/CSS or React/Vue/Angular to custom nodes and edges
- 🚀 Out-of-the-box: built-in 10+ plugins, such as selection, dnd, redo/undo, snapline, minimap, etc.
- 🧲 Data-driven: base on MVC architecture, you can focus on data logic and business logic
- 💯 Highly-event-driven: you can react on any event that happens inside the graph
- 🌱   Easy-to-customize: based on well known SVG/HTML/CSS or React/Vue/Angular to custom nodes and edges
- 🚀   Out-of-the-box: built-in 10+ plugins, such as selection, dnd, redo/undo, snapline, minimap, etc.
- 🧲   Data-driven: base on MVC architecture, you can focus on data logic and business logic
- 💯   Highly-event-driven: you can react on any event that happens inside the graph
## Environment Support
@ -33,8 +33,8 @@
- Server-side Rendering
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/edge/edge_48x48.png" alt="IE / Edge" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>IE / Edge | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions |
| --- | --- | --- | --- |
| IE11, Edge | last 2 versions | last 2 versions | last 2 versions |
## Installation
@ -57,7 +57,7 @@ import { Graph } from '@antv/x6'
const graph = new Graph({
container: document.getElementById('container'),
grid: true
grid: true,
})
const source = graph.addNode({
@ -89,7 +89,7 @@ graph.addEdge({
- [Blog](https://www.yuque.com/antv/x6/gcinvi)
- [Versioning Release Note](https://www.yuque.com/antv/x6/bbfu6r)
- [FAQ](https://www.yuque.com/antv/x6/be9pfx)
- [CodeSanbox Template](https://codesandbox.io/s/qosj0?file=/src/app.tsx)
- [Template](https://codesandbox.io/s/qosj0?file=/src/app.tsx)
- [awesome-x6](https://github.com/lloydzhou/awesome-x6)
## Development

View File

@ -21,10 +21,10 @@
## 特性
- 🌱 极易定制:支持使用 SVG/HTML/React/Vue/Angular 定制节点样式和交互
- 🚀 开箱即用:内置 10+ 图编辑配套扩展,如框选、对齐线、小地图等
- 🧲 数据驱动:基于 MVC 架构,用户更加专注于数据逻辑和业务逻辑
- 💯 事件驱动:完备的事件系统,可以监听图表内发生的任何事件
- 🌱  极易定制:支持使用 SVG/HTML/React/Vue/Angular 定制节点样式和交互
- 🚀  开箱即用:内置 10+ 图编辑配套扩展,如框选、对齐线、小地图等
- 🧲  数据驱动:基于 MVC 架构,用户更加专注于数据逻辑和业务逻辑
- 💯  事件驱动:完备的事件系统,可以监听图表内发生的任何事件
## 兼容环境
@ -32,8 +32,8 @@
- 支持服务端渲染。
| [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/firefox/firefox_48x48.png" alt="Firefox" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Firefox | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/chrome/chrome_48x48.png" alt="Chrome" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Chrome | [<img src="https://raw.githubusercontent.com/alrra/browser-logos/master/src/safari/safari_48x48.png" alt="Safari" width="24px" height="24px" />](http://godban.github.io/browsers-support-badges/)<br>Safari |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| last 2 versions | last 2 versions | last 2 versions |
| --- | --- | --- |
| last 2 versions | last 2 versions | last 2 versions |
## 安装
@ -56,7 +56,7 @@ import { Graph } from '@antv/x6'
const graph = new Graph({
container: document.getElementById('container'),
grid: true
grid: true,
})
const source = graph.addNode({
@ -88,7 +88,7 @@ graph.addEdge({
- [博客](https://www.yuque.com/antv/x6/huhla47wqalq5n7r)
- [更新日志](https://www.yuque.com/antv/x6/bbfu6r)
- [常见问题](https://www.yuque.com/antv/x6/tox1ukbz5cw57qfy)
- [CodeSanbox 模板](https://codesandbox.io/s/mo-ban-wchooy?file=/src/App.tsx)
- [复现模板](https://codesandbox.io/s/mo-ban-55i8dp)
- [awesome-x6](https://github.com/lloydzhou/awesome-x6)
## 本地开发
@ -114,7 +114,6 @@ pnpm run start
<img src="https://raw.githubusercontent.com/antvis/X6/master/CONTRIBUTORS.svg" alt="Contributors" />
</a>
## 开源协议
该项目的代码和文档基于 [MIT License](/LICENSE) 开源协议。

View File

@ -2,8 +2,7 @@
## Supported Versions
Use this section to tell people about which versions of your project are
currently being supported with security updates.
Use this section to tell people about which versions of your project are currently being supported with security updates.
| Version | Supported |
| ------- | ------------------ |
@ -16,6 +15,4 @@ currently being supported with security updates.
Use this section to tell people how to report a vulnerability.
Tell them where to go, how often they can expect to get an update on a
reported vulnerability, what to expect if the vulnerability is accepted or
declined, etc.
Tell them where to go, how often they can expect to get an update on a reported vulnerability, what to expect if the vulnerability is accepted or declined, etc.

View File

@ -1,122 +1,112 @@
## @antv/x6-example-features [2.1.1](https://github.com/antvis/X6/compare/@antv/x6-example-features@2.1.0...@antv/x6-example-features@2.1.1) (2023-02-18)
### Bug Fixes
* mindmap demo duplicate node id, close [#3256](https://github.com/antvis/X6/issues/3256) ([#3257](https://github.com/antvis/X6/issues/3257)) ([c510756](https://github.com/antvis/X6/commit/c510756fe4e96c8e7471c2fb558e6019ec69b057))
- mindmap demo duplicate node id, close [#3256](https://github.com/antvis/X6/issues/3256) ([#3257](https://github.com/antvis/X6/issues/3257)) ([c510756](https://github.com/antvis/X6/commit/c510756fe4e96c8e7471c2fb558e6019ec69b057))
# @antv/x6-example-features [2.1.0](https://github.com/antvis/X6/compare/@antv/x6-example-features@2.0.3...@antv/x6-example-features@2.1.0) (2023-02-17)
### Features
* history add max stack size ([#3253](https://github.com/antvis/X6/issues/3253)) ([fba5310](https://github.com/antvis/X6/commit/fba531064ad8027c451a81b60d5efd7f7314a0fa))
- history add max stack size ([#3253](https://github.com/antvis/X6/issues/3253)) ([fba5310](https://github.com/antvis/X6/commit/fba531064ad8027c451a81b60d5efd7f7314a0fa))
## @antv/x6-example-features [2.0.2](https://github.com/antvis/X6/compare/@antv/x6-example-features@2.0.1...@antv/x6-example-features@2.0.2) (2023-01-17)
### Bug Fixes
* **mindmap demo:** can not find target id when create edge ([#3144](https://github.com/antvis/X6/issues/3144)) ([bfc8d7f](https://github.com/antvis/X6/commit/bfc8d7f17ac900f70b696c1fa7a3f3f3a389103f))
- **mindmap demo:** can not find target id when create edge ([#3144](https://github.com/antvis/X6/issues/3144)) ([bfc8d7f](https://github.com/antvis/X6/commit/bfc8d7f17ac900f70b696c1fa7a3f3f3a389103f))
## @antv/x6-example-features [2.0.1](https://github.com/antvis/X6/compare/@antv/x6-example-features@2.0.0...@antv/x6-example-features@2.0.1) (2022-12-16)
### Bug Fixes
* make resizing options take effect ([#3014](https://github.com/antvis/X6/issues/3014)) ([604c024](https://github.com/antvis/X6/commit/604c0244cd71ec8e911754dfe524f12c04e4e9ad))
- make resizing options take effect ([#3014](https://github.com/antvis/X6/issues/3014)) ([604c024](https://github.com/antvis/X6/commit/604c0244cd71ec8e911754dfe524f12c04e4e9ad))
# @antv/x6-example-features [2.0.0](https://github.com/antvis/X6/compare/@antv/x6-example-features@1.1.2...@antv/x6-example-features@2.0.0) (2022-11-24)
### Bug Fixes
* 🐛 add return value for autoScroller in scroller plugin ([5e102a3](https://github.com/antvis/X6/commit/5e102a39c5bd14a478edd4f36c4264997027c2a9))
* 🐛 add timeout for schedule ([#2303](https://github.com/antvis/X6/issues/2303)) ([a6a2d12](https://github.com/antvis/X6/commit/a6a2d12b07add27ef19eebbf7b5ca7cd17dde09e))
* 🐛 break text with chinese characters(double byte character) ([14199bc](https://github.com/antvis/X6/commit/14199bc8529adddb347ef934926503a789b64980)), closes [#596](https://github.com/antvis/X6/issues/596)
* 🐛 change jobqueue to transient ([0e39d94](https://github.com/antvis/X6/commit/0e39d9447bc8c0ba0b11c272bf9b64df9ba95a33))
* 🐛 do not generate new commands on redoing/undoing ([5b3d713](https://github.com/antvis/X6/commit/5b3d7133f3a7b4841f461e67af5963ec84820741)), closes [#627](https://github.com/antvis/X6/issues/627)
* 🐛 do not update pagesize automatically when set graph size ([949a42d](https://github.com/antvis/X6/commit/949a42dacfc5023d25bcabc0a3a1a7d8578f1b96)), closes [#644](https://github.com/antvis/X6/issues/644) [#564](https://github.com/antvis/X6/issues/564)
* 🐛 fix add tools not work ([f5d1d6a](https://github.com/antvis/X6/commit/f5d1d6a326021247ee8967675fc9490ddbb6d0aa))
* 🐛 fix model event trigger twice ([#789](https://github.com/antvis/X6/issues/789)) ([7638143](https://github.com/antvis/X6/commit/7638143b04c0a50a333200423753f6bd19a6ceb3))
* 🐛 fix running error of x6-example-demo ([#1111](https://github.com/antvis/X6/issues/1111)) ([d5c854f](https://github.com/antvis/X6/commit/d5c854f644e4926dba2913a216870bdbaafd425a))
* 🐛 fix the error in selected nodes position when snapline enabled ([#2797](https://github.com/antvis/X6/issues/2797)) ([1e7f132](https://github.com/antvis/X6/commit/1e7f132bed15006cc5535f1294f0b8a545dd6441))
* 🐛 fix type error ([30ca7a9](https://github.com/antvis/X6/commit/30ca7a92817d28e58589413e36d3d2931360b8ae))
* 🐛 fix x6-react-components version in demo ([709cdae](https://github.com/antvis/X6/commit/709cdae33d13acfd77af11e8bb5fb4f493dd5bd5))
* 🐛 interact with input rendered in react component ([82478b1](https://github.com/antvis/X6/commit/82478b1d66e3b8b4346dab9041cb00e54fea9be1))
* 🐛 linear gradient along edge path ([669fc5b](https://github.com/antvis/X6/commit/669fc5bd2d57635ce9d45dc0470674dad74f4add)), closes [#635](https://github.com/antvis/X6/issues/635)
* 🐛 liner gradient not available on horizontal and vertical edges ([333689a](https://github.com/antvis/X6/commit/333689a880a30dbc0879705b7f655cec8d30f1df)), closes [#635](https://github.com/antvis/X6/issues/635)
* 🐛 optimize cell remove method ([391fe8f](https://github.com/antvis/X6/commit/391fe8fd88f10d936c5860f465c7a423632f30f9))
* 🐛 optimize contextmenu tools ([#1391](https://github.com/antvis/X6/issues/1391)) ([cc01fdf](https://github.com/antvis/X6/commit/cc01fdf208f4fbd283a6ce3d7a106716e8e10300))
* 🐛 set the async of minimapGraph to be the same as sourceGraph ([9dded68](https://github.com/antvis/X6/commit/9dded6853d66b86e7bbeb738b2df15b51d1a8627))
* 🐛 should render vertices tool with lowest z-index ([213a01f](https://github.com/antvis/X6/commit/213a01fca28b1e790ce58d228aa460ea798bb98f)), closes [#638](https://github.com/antvis/X6/issues/638)
* 🐛 update x6-react-shape version ([#1425](https://github.com/antvis/X6/issues/1425)) ([4208846](https://github.com/antvis/X6/commit/4208846337326d8983f1662faa8da67efd8568b4))
* fix contextmenu show multiple times ([5d437ce](https://github.com/antvis/X6/commit/5d437cef07427bf9f2cbae9b2e08dd4a6544ff70))
* fix demo import path error ([2ebf581](https://github.com/antvis/X6/commit/2ebf581dc1ec9c5ee4501917a7cbddbbb4b69c0f))
* fix path error in custom router demo ([#620](https://github.com/antvis/X6/issues/620)) ([7cd3a7e](https://github.com/antvis/X6/commit/7cd3a7e57d772481ad33949ee832a36aab59ef3a))
* refactor example ([#2831](https://github.com/antvis/X6/issues/2831)) ([3d8f005](https://github.com/antvis/X6/commit/3d8f005696021f1d9f91a96812ebadce179f2d73))
* remove x6-common and x6-geometry deps ([#2830](https://github.com/antvis/X6/issues/2830)) ([5b5f5aa](https://github.com/antvis/X6/commit/5b5f5aa7ea6fded1b15abc79b9b5a5e2281b3ab9))
* update dependencies and fix type errors ([#1103](https://github.com/antvis/X6/issues/1103)) ([49d4371](https://github.com/antvis/X6/commit/49d43716ada672e609e4e6d9c6fdca3f494b6f68))
* **wip:** 🐛 click event of contextmenu was not triggered ([2c9363e](https://github.com/antvis/X6/commit/2c9363e46904979901d4b467995d289c094d329a))
- 🐛 add return value for autoScroller in scroller plugin ([5e102a3](https://github.com/antvis/X6/commit/5e102a39c5bd14a478edd4f36c4264997027c2a9))
- 🐛 add timeout for schedule ([#2303](https://github.com/antvis/X6/issues/2303)) ([a6a2d12](https://github.com/antvis/X6/commit/a6a2d12b07add27ef19eebbf7b5ca7cd17dde09e))
- 🐛 break text with chinese characters(double byte character) ([14199bc](https://github.com/antvis/X6/commit/14199bc8529adddb347ef934926503a789b64980)), closes [#596](https://github.com/antvis/X6/issues/596)
- 🐛 change jobqueue to transient ([0e39d94](https://github.com/antvis/X6/commit/0e39d9447bc8c0ba0b11c272bf9b64df9ba95a33))
- 🐛 do not generate new commands on redoing/undoing ([5b3d713](https://github.com/antvis/X6/commit/5b3d7133f3a7b4841f461e67af5963ec84820741)), closes [#627](https://github.com/antvis/X6/issues/627)
- 🐛 do not update pagesize automatically when set graph size ([949a42d](https://github.com/antvis/X6/commit/949a42dacfc5023d25bcabc0a3a1a7d8578f1b96)), closes [#644](https://github.com/antvis/X6/issues/644) [#564](https://github.com/antvis/X6/issues/564)
- 🐛 fix add tools not work ([f5d1d6a](https://github.com/antvis/X6/commit/f5d1d6a326021247ee8967675fc9490ddbb6d0aa))
- 🐛 fix model event trigger twice ([#789](https://github.com/antvis/X6/issues/789)) ([7638143](https://github.com/antvis/X6/commit/7638143b04c0a50a333200423753f6bd19a6ceb3))
- 🐛 fix running error of x6-example-demo ([#1111](https://github.com/antvis/X6/issues/1111)) ([d5c854f](https://github.com/antvis/X6/commit/d5c854f644e4926dba2913a216870bdbaafd425a))
- 🐛 fix the error in selected nodes position when snapline enabled ([#2797](https://github.com/antvis/X6/issues/2797)) ([1e7f132](https://github.com/antvis/X6/commit/1e7f132bed15006cc5535f1294f0b8a545dd6441))
- 🐛 fix type error ([30ca7a9](https://github.com/antvis/X6/commit/30ca7a92817d28e58589413e36d3d2931360b8ae))
- 🐛 fix x6-react-components version in demo ([709cdae](https://github.com/antvis/X6/commit/709cdae33d13acfd77af11e8bb5fb4f493dd5bd5))
- 🐛 interact with input rendered in react component ([82478b1](https://github.com/antvis/X6/commit/82478b1d66e3b8b4346dab9041cb00e54fea9be1))
- 🐛 linear gradient along edge path ([669fc5b](https://github.com/antvis/X6/commit/669fc5bd2d57635ce9d45dc0470674dad74f4add)), closes [#635](https://github.com/antvis/X6/issues/635)
- 🐛 liner gradient not available on horizontal and vertical edges ([333689a](https://github.com/antvis/X6/commit/333689a880a30dbc0879705b7f655cec8d30f1df)), closes [#635](https://github.com/antvis/X6/issues/635)
- 🐛 optimize cell remove method ([391fe8f](https://github.com/antvis/X6/commit/391fe8fd88f10d936c5860f465c7a423632f30f9))
- 🐛 optimize contextmenu tools ([#1391](https://github.com/antvis/X6/issues/1391)) ([cc01fdf](https://github.com/antvis/X6/commit/cc01fdf208f4fbd283a6ce3d7a106716e8e10300))
- 🐛 set the async of minimapGraph to be the same as sourceGraph ([9dded68](https://github.com/antvis/X6/commit/9dded6853d66b86e7bbeb738b2df15b51d1a8627))
- 🐛 should render vertices tool with lowest z-index ([213a01f](https://github.com/antvis/X6/commit/213a01fca28b1e790ce58d228aa460ea798bb98f)), closes [#638](https://github.com/antvis/X6/issues/638)
- 🐛 update x6-react-shape version ([#1425](https://github.com/antvis/X6/issues/1425)) ([4208846](https://github.com/antvis/X6/commit/4208846337326d8983f1662faa8da67efd8568b4))
- fix contextmenu show multiple times ([5d437ce](https://github.com/antvis/X6/commit/5d437cef07427bf9f2cbae9b2e08dd4a6544ff70))
- fix demo import path error ([2ebf581](https://github.com/antvis/X6/commit/2ebf581dc1ec9c5ee4501917a7cbddbbb4b69c0f))
- fix path error in custom router demo ([#620](https://github.com/antvis/X6/issues/620)) ([7cd3a7e](https://github.com/antvis/X6/commit/7cd3a7e57d772481ad33949ee832a36aab59ef3a))
- refactor example ([#2831](https://github.com/antvis/X6/issues/2831)) ([3d8f005](https://github.com/antvis/X6/commit/3d8f005696021f1d9f91a96812ebadce179f2d73))
- remove x6-common and x6-geometry deps ([#2830](https://github.com/antvis/X6/issues/2830)) ([5b5f5aa](https://github.com/antvis/X6/commit/5b5f5aa7ea6fded1b15abc79b9b5a5e2281b3ab9))
- update dependencies and fix type errors ([#1103](https://github.com/antvis/X6/issues/1103)) ([49d4371](https://github.com/antvis/X6/commit/49d43716ada672e609e4e6d9c6fdca3f494b6f68))
- **wip:** 🐛 click event of contextmenu was not triggered ([2c9363e](https://github.com/antvis/X6/commit/2c9363e46904979901d4b467995d289c094d329a))
### chore
* release beta ([b5f3cfa](https://github.com/antvis/X6/commit/b5f3cfa2042f5196a995a38a8f41f140cabdce57))
- release beta ([b5f3cfa](https://github.com/antvis/X6/commit/b5f3cfa2042f5196a995a38a8f41f140cabdce57))
### Documentation
* refresh changelogs ([44f89a1](https://github.com/antvis/X6/commit/44f89a1e1a85513a9bf548be87be38e3cdc82574))
- refresh changelogs ([44f89a1](https://github.com/antvis/X6/commit/44f89a1e1a85513a9bf548be87be38e3cdc82574))
### Features
* ✨ add `primer` and `useForeignObject` option for react-shape ([ab6a06f](https://github.com/antvis/X6/commit/ab6a06f1fe70b71ae31acc47b0d9cb02c86097e2))
* ✨ add autoResize feature ([5aeae97](https://github.com/antvis/X6/commit/5aeae976cd7638b2b5c05bc12bc56b562366fe5f))
* ✨ add clipboard plugin ([8107f6d](https://github.com/antvis/X6/commit/8107f6df5de52a33e1b8094a44d59ee7fd2a8042))
* ✨ add dnd plugin ([269fae9](https://github.com/antvis/X6/commit/269fae9e5eeb969c6a7884373aa3a32002c064e6))
* ✨ add history plugin ([#2819](https://github.com/antvis/X6/issues/2819)) ([fd8d384](https://github.com/antvis/X6/commit/fd8d384a29d0f2e02bf066efd19ed3f92614c524))
* ✨ add html shape ([8d75504](https://github.com/antvis/X6/commit/8d7550413f9f6f3177eab9d0f7fef14c55949fb8))
* ✨ add keyboard plugin ([#2665](https://github.com/antvis/X6/issues/2665)) ([bf53677](https://github.com/antvis/X6/commit/bf536778ca7ee3229390dfcfcb085ec55edd9fb2))
* ✨ add library for manipulating and animating SVG ([c07a177](https://github.com/antvis/X6/commit/c07a17785fc99372baaa66ea2525acf1d332fa11))
* ✨ add minimap plugin ([6cdecbb](https://github.com/antvis/X6/commit/6cdecbbba9a4db1f67189e23fb89f2a7ba2af99e))
* ✨ add panning and mousewheel module ([#2243](https://github.com/antvis/X6/issues/2243)) ([55d36e4](https://github.com/antvis/X6/commit/55d36e46808a4c79b086d7798bce396d5211a1dc))
* ✨ add scroller api ([12173bf](https://github.com/antvis/X6/commit/12173bf500624f197ed56cf6a797499587178cba))
* ✨ add selection plugin ([#2742](https://github.com/antvis/X6/issues/2742)) ([50a5dc7](https://github.com/antvis/X6/commit/50a5dc7cd8c2e39a1f8bf8359a0eb189dda8cb86))
* ✨ add snapline plugin ([294672b](https://github.com/antvis/X6/commit/294672b3066b15ab834ce2a3172facc49004c950))
* ✨ add some missing api ([1dcb3d9](https://github.com/antvis/X6/commit/1dcb3d92fd83e5dfd1a1af9670d539a99dd9f55a))
* ✨ add stencil plugin ([#2815](https://github.com/antvis/X6/issues/2815)) ([4e1fb7b](https://github.com/antvis/X6/commit/4e1fb7bef8ff5548edf2529eb27be0a66a600996))
* ✨ add transform plugin ([#2818](https://github.com/antvis/X6/issues/2818)) ([660e2d7](https://github.com/antvis/X6/commit/660e2d7689bfa59a0f4a4a5e3c0ace70dec21e9e))
* ✨ add virtual render feature ([#2198](https://github.com/antvis/X6/issues/2198)) ([fcba5e1](https://github.com/antvis/X6/commit/fcba5e14808d44c80b658c090cc2a4ebcdc64f6d))
* ✨ add xmind demo ([adb2c98](https://github.com/antvis/X6/commit/adb2c98e23e93b7084fd20f05801f2595d4ac990))
* ✨ auto resize graph when container resized ([9c7bc9a](https://github.com/antvis/X6/commit/9c7bc9a4bb210451283663cd99a29bd6c79e2ec4)), closes [#531](https://github.com/antvis/X6/issues/531)
* ✨ export common and geometry in x6 package ([#2820](https://github.com/antvis/X6/issues/2820)) ([df28200](https://github.com/antvis/X6/commit/df282000cc5e17521147c77c210e172c444c9938))
* ✨ expose the selection api ([#2756](https://github.com/antvis/X6/issues/2756)) ([f3edbbc](https://github.com/antvis/X6/commit/f3edbbc95d2038a61116fa71bb0c3016f1c92d5e))
* ✨ improve auto-resize feature ([40d5335](https://github.com/antvis/X6/commit/40d53355cedc0bbbeb1e26948b67254dc6a40d85))
* ✨ random path demo ([38ec683](https://github.com/antvis/X6/commit/38ec683673e2da64296521f23a91f951a442adc0))
* ✨ support inherit options for react-shape registry ([#2596](https://github.com/antvis/X6/issues/2596)) ([ad63046](https://github.com/antvis/X6/commit/ad63046e89fa5853b0cf15947af1ed2a7b625188))
* ✨ support panning scroller graph byrightmousedown ([6ffdb50](https://github.com/antvis/X6/commit/6ffdb5004401b30ff5852a08de9286a934780be3))
* add scroller plugin ([#2580](https://github.com/antvis/X6/issues/2580)) ([5e0e2ac](https://github.com/antvis/X6/commit/5e0e2acde7d7e259ea27d001983e950878d0ecc8))
* attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/X6/issues/2864)) ([774f547](https://github.com/antvis/X6/commit/774f547b85522eb2411dca949d36ecfe535503f3))
* force release 2.0-beta ([6987d9c](https://github.com/antvis/X6/commit/6987d9ce64454cd76f697d33f96715dbdf56524a))
* support mouseenter and mouseleave event ([#2559](https://github.com/antvis/X6/issues/2559)) ([ecfd426](https://github.com/antvis/X6/commit/ecfd4263b1266a128bf8651c4dd745ff8ab038b3))
* sync code from master ([#2004](https://github.com/antvis/X6/issues/2004)) ([c681405](https://github.com/antvis/X6/commit/c68140504bd21f654870f3d2fc1ad2f16f1113c8)), closes [#1974](https://github.com/antvis/X6/issues/1974) [#1977](https://github.com/antvis/X6/issues/1977) [#1985](https://github.com/antvis/X6/issues/1985) [#1988](https://github.com/antvis/X6/issues/1988) [#1991](https://github.com/antvis/X6/issues/1991) [#1989](https://github.com/antvis/X6/issues/1989)
* upgrade react to 18 in react-components ([#2836](https://github.com/antvis/X6/issues/2836)) ([5138562](https://github.com/antvis/X6/commit/5138562515ddbd3975adc9d93514f21d6fc2bb3e))
- ✨ add `primer` and `useForeignObject` option for react-shape ([ab6a06f](https://github.com/antvis/X6/commit/ab6a06f1fe70b71ae31acc47b0d9cb02c86097e2))
- ✨ add autoResize feature ([5aeae97](https://github.com/antvis/X6/commit/5aeae976cd7638b2b5c05bc12bc56b562366fe5f))
- ✨ add clipboard plugin ([8107f6d](https://github.com/antvis/X6/commit/8107f6df5de52a33e1b8094a44d59ee7fd2a8042))
- ✨ add dnd plugin ([269fae9](https://github.com/antvis/X6/commit/269fae9e5eeb969c6a7884373aa3a32002c064e6))
- ✨ add history plugin ([#2819](https://github.com/antvis/X6/issues/2819)) ([fd8d384](https://github.com/antvis/X6/commit/fd8d384a29d0f2e02bf066efd19ed3f92614c524))
- ✨ add html shape ([8d75504](https://github.com/antvis/X6/commit/8d7550413f9f6f3177eab9d0f7fef14c55949fb8))
- ✨ add keyboard plugin ([#2665](https://github.com/antvis/X6/issues/2665)) ([bf53677](https://github.com/antvis/X6/commit/bf536778ca7ee3229390dfcfcb085ec55edd9fb2))
- ✨ add library for manipulating and animating SVG ([c07a177](https://github.com/antvis/X6/commit/c07a17785fc99372baaa66ea2525acf1d332fa11))
- ✨ add minimap plugin ([6cdecbb](https://github.com/antvis/X6/commit/6cdecbbba9a4db1f67189e23fb89f2a7ba2af99e))
- ✨ add panning and mousewheel module ([#2243](https://github.com/antvis/X6/issues/2243)) ([55d36e4](https://github.com/antvis/X6/commit/55d36e46808a4c79b086d7798bce396d5211a1dc))
- ✨ add scroller api ([12173bf](https://github.com/antvis/X6/commit/12173bf500624f197ed56cf6a797499587178cba))
- ✨ add selection plugin ([#2742](https://github.com/antvis/X6/issues/2742)) ([50a5dc7](https://github.com/antvis/X6/commit/50a5dc7cd8c2e39a1f8bf8359a0eb189dda8cb86))
- ✨ add snapline plugin ([294672b](https://github.com/antvis/X6/commit/294672b3066b15ab834ce2a3172facc49004c950))
- ✨ add some missing api ([1dcb3d9](https://github.com/antvis/X6/commit/1dcb3d92fd83e5dfd1a1af9670d539a99dd9f55a))
- ✨ add stencil plugin ([#2815](https://github.com/antvis/X6/issues/2815)) ([4e1fb7b](https://github.com/antvis/X6/commit/4e1fb7bef8ff5548edf2529eb27be0a66a600996))
- ✨ add transform plugin ([#2818](https://github.com/antvis/X6/issues/2818)) ([660e2d7](https://github.com/antvis/X6/commit/660e2d7689bfa59a0f4a4a5e3c0ace70dec21e9e))
- ✨ add virtual render feature ([#2198](https://github.com/antvis/X6/issues/2198)) ([fcba5e1](https://github.com/antvis/X6/commit/fcba5e14808d44c80b658c090cc2a4ebcdc64f6d))
- ✨ add xmind demo ([adb2c98](https://github.com/antvis/X6/commit/adb2c98e23e93b7084fd20f05801f2595d4ac990))
- ✨ auto resize graph when container resized ([9c7bc9a](https://github.com/antvis/X6/commit/9c7bc9a4bb210451283663cd99a29bd6c79e2ec4)), closes [#531](https://github.com/antvis/X6/issues/531)
- ✨ export common and geometry in x6 package ([#2820](https://github.com/antvis/X6/issues/2820)) ([df28200](https://github.com/antvis/X6/commit/df282000cc5e17521147c77c210e172c444c9938))
- ✨ expose the selection api ([#2756](https://github.com/antvis/X6/issues/2756)) ([f3edbbc](https://github.com/antvis/X6/commit/f3edbbc95d2038a61116fa71bb0c3016f1c92d5e))
- ✨ improve auto-resize feature ([40d5335](https://github.com/antvis/X6/commit/40d53355cedc0bbbeb1e26948b67254dc6a40d85))
- ✨ random path demo ([38ec683](https://github.com/antvis/X6/commit/38ec683673e2da64296521f23a91f951a442adc0))
- ✨ support inherit options for react-shape registry ([#2596](https://github.com/antvis/X6/issues/2596)) ([ad63046](https://github.com/antvis/X6/commit/ad63046e89fa5853b0cf15947af1ed2a7b625188))
- ✨ support panning scroller graph byrightmousedown ([6ffdb50](https://github.com/antvis/X6/commit/6ffdb5004401b30ff5852a08de9286a934780be3))
- add scroller plugin ([#2580](https://github.com/antvis/X6/issues/2580)) ([5e0e2ac](https://github.com/antvis/X6/commit/5e0e2acde7d7e259ea27d001983e950878d0ecc8))
- attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/X6/issues/2864)) ([774f547](https://github.com/antvis/X6/commit/774f547b85522eb2411dca949d36ecfe535503f3))
- force release 2.0-beta ([6987d9c](https://github.com/antvis/X6/commit/6987d9ce64454cd76f697d33f96715dbdf56524a))
- support mouseenter and mouseleave event ([#2559](https://github.com/antvis/X6/issues/2559)) ([ecfd426](https://github.com/antvis/X6/commit/ecfd4263b1266a128bf8651c4dd745ff8ab038b3))
- sync code from master ([#2004](https://github.com/antvis/X6/issues/2004)) ([c681405](https://github.com/antvis/X6/commit/c68140504bd21f654870f3d2fc1ad2f16f1113c8)), closes [#1974](https://github.com/antvis/X6/issues/1974) [#1977](https://github.com/antvis/X6/issues/1977) [#1985](https://github.com/antvis/X6/issues/1985) [#1988](https://github.com/antvis/X6/issues/1988) [#1991](https://github.com/antvis/X6/issues/1991) [#1989](https://github.com/antvis/X6/issues/1989)
- upgrade react to 18 in react-components ([#2836](https://github.com/antvis/X6/issues/2836)) ([5138562](https://github.com/antvis/X6/commit/5138562515ddbd3975adc9d93514f21d6fc2bb3e))
### Performance Improvements
* ⚡️ add getMatrixByElementAttr and getBBoxByElementAttr to reduce reflow ([ba5b22a](https://github.com/antvis/X6/commit/ba5b22a33a0af067d77735c5cc46a60a45734dca))
* ⚡️ add simple config to remove rect and text element ([#1449](https://github.com/antvis/X6/issues/1449)) ([0b5f241](https://github.com/antvis/X6/commit/0b5f2413f0b907316784149027615ae2d09616a4))
* ⚡️ check whether label existed in port ([#2063](https://github.com/antvis/X6/issues/2063)) ([5ae7271](https://github.com/antvis/X6/commit/5ae7271a25e804a9321aa80e31dcf6e43144728b))
* ⚡️ optimize breakText for a high performance version ([#2242](https://github.com/antvis/X6/issues/2242)) ([0aced58](https://github.com/antvis/X6/commit/0aced58056d908ec092bca1889b5ef367a94fe68))
* ⚡️ optimize node render performance ([6554959](https://github.com/antvis/X6/commit/65549599d2f82f8052d16776c8d36ce7ee2fba9b))
* ⚡️ repalce getTransformToElement and getBBox to improve performance ([#2177](https://github.com/antvis/X6/issues/2177)) ([1436586](https://github.com/antvis/X6/commit/1436586f85cc2e2f6ec71548f6d6c232be793154))
- ⚡️ add getMatrixByElementAttr and getBBoxByElementAttr to reduce reflow ([ba5b22a](https://github.com/antvis/X6/commit/ba5b22a33a0af067d77735c5cc46a60a45734dca))
- ⚡️ add simple config to remove rect and text element ([#1449](https://github.com/antvis/X6/issues/1449)) ([0b5f241](https://github.com/antvis/X6/commit/0b5f2413f0b907316784149027615ae2d09616a4))
- ⚡️ check whether label existed in port ([#2063](https://github.com/antvis/X6/issues/2063)) ([5ae7271](https://github.com/antvis/X6/commit/5ae7271a25e804a9321aa80e31dcf6e43144728b))
- ⚡️ optimize breakText for a high performance version ([#2242](https://github.com/antvis/X6/issues/2242)) ([0aced58](https://github.com/antvis/X6/commit/0aced58056d908ec092bca1889b5ef367a94fe68))
- ⚡️ optimize node render performance ([6554959](https://github.com/antvis/X6/commit/65549599d2f82f8052d16776c8d36ce7ee2fba9b))
- ⚡️ repalce getTransformToElement and getBBox to improve performance ([#2177](https://github.com/antvis/X6/issues/2177)) ([1436586](https://github.com/antvis/X6/commit/1436586f85cc2e2f6ec71548f6d6c232be793154))
### BREAKING CHANGES
* dump to 2.0
* force release 2.0-beta
* 2.0-beta
- dump to 2.0
- force release 2.0-beta
- 2.0-beta

View File

@ -9,20 +9,20 @@
},
"dependencies": {
"@antv/hierarchy": "^0.6.8",
"@antv/x6": "^2.x",
"@antv/x6-plugin-clipboard": "^2.x",
"@antv/x6-plugin-dnd": "^2.x",
"@antv/x6-plugin-export": "^2.x",
"@antv/x6-plugin-history": "^2.x",
"@antv/x6-plugin-keyboard": "^2.x",
"@antv/x6-plugin-minimap": "^2.x",
"@antv/x6-plugin-scroller": "^2.x",
"@antv/x6-plugin-selection": "^2.x",
"@antv/x6-plugin-snapline": "^2.x",
"@antv/x6-plugin-stencil": "^2.x",
"@antv/x6-plugin-transform": "^2.x",
"@antv/x6-react-components": "^2.x",
"@antv/x6-react-shape": "^2.x",
"@antv/x6": "workspace:latest",
"@antv/x6-plugin-clipboard": "workspace:latest",
"@antv/x6-plugin-dnd": "workspace:latest",
"@antv/x6-plugin-export": "workspace:latest",
"@antv/x6-plugin-history": "workspace:latest",
"@antv/x6-plugin-keyboard": "workspace:latest",
"@antv/x6-plugin-minimap": "workspace:latest",
"@antv/x6-plugin-scroller": "workspace:latest",
"@antv/x6-plugin-selection": "workspace:latest",
"@antv/x6-plugin-snapline": "workspace:latest",
"@antv/x6-plugin-stencil": "workspace:latest",
"@antv/x6-plugin-transform": "workspace:latest",
"@antv/x6-react-components": "workspace:latest",
"@antv/x6-react-shape": "workspace:latest",
"antd": "^4.4.2",
"classnames": "^2.2.6",
"dagre": "^0.8.5",

View File

@ -35,11 +35,7 @@ export default class Example extends React.Component {
},
autoResize: true,
})
graph.use(
new Scroller({
enabled: true,
}),
)
graph.use(new Scroller())
}
refContainer1 = (container: HTMLDivElement) => {

View File

@ -10,7 +10,6 @@ export default class Example extends React.Component {
container: this.container,
width: 800,
height: 600,
grid: true,
})
const source = graph.addNode({

View File

@ -374,7 +374,6 @@ export default class Example extends React.Component {
})
const selection = new Selection({
enabled: true,
multiple: true,
rubberEdge: true,
rubberNode: true,
@ -382,7 +381,7 @@ export default class Example extends React.Component {
rubberband: true,
})
graph.use(selection)
graph.use(new Snapline({ enabled: true }))
graph.use(new Snapline())
graph.on('edge:connected', ({ edge }) => {
edge.attr({

View File

@ -184,13 +184,9 @@ export default class Example extends React.Component {
connectionPoint: 'anchor',
},
})
const selection = new Selection({
enabled: true,
})
const selection = new Selection()
graph.use(selection)
const keyboard = new Keyboard({
enabled: true,
})
const keyboard = new Keyboard()
graph.use(keyboard)
const render = () => {

View File

@ -18,19 +18,13 @@ export default class Example extends React.Component {
height: 600,
grid: true,
})
const clipboard = new Clipboard({
enabled: true,
useLocalStorage: true,
})
const clipboard = new Clipboard()
const selection = new Selection({
enabled: true,
rubberband: true,
multiple: true,
strict: true,
})
const keyboard = new Keyboard({
enabled: true,
})
const keyboard = new Keyboard()
graph.use(clipboard)
graph.use(selection)

View File

@ -3,13 +3,12 @@ import { Graph } from '@antv/x6'
import { Keyboard } from '@antv/x6-plugin-keyboard'
import { Selection } from '@antv/x6-plugin-selection'
import { History } from '@antv/x6-plugin-history'
import { Button } from 'antd'
import '../index.less'
export default class Example extends React.Component<
{},
{ graph: Graph | undefined }
> {
export default class Example extends React.Component {
private container: HTMLDivElement
private graph: Graph
componentDidMount() {
const graph = new Graph({
@ -19,11 +18,9 @@ export default class Example extends React.Component<
grid: true,
})
this.setState({ graph })
const selection = new Selection({ enabled: true })
const keyboard = new Keyboard({ enabled: true })
const history = new History({ enabled: true, stackSize: 5 })
const selection = new Selection()
const keyboard = new Keyboard()
const history = new History({ stackSize: 5 })
graph.use(selection)
graph.use(keyboard)
@ -62,6 +59,8 @@ export default class Example extends React.Component<
keyboard.bindKey('command+shift+z', () => {
this.redo()
})
this.graph = graph
}
refContainer = (container: HTMLDivElement) => {
@ -69,35 +68,31 @@ export default class Example extends React.Component<
}
enablePlugins = () => {
const { graph } = this.state
graph?.enablePlugins('keyboard')
this.graph.enablePlugins('history')
}
disablePlugins = () => {
const { graph } = this.state
graph?.disablePlugins('keyboard')
this.graph.disablePlugins('history')
}
undo = () => {
const { graph } = this.state
const history = graph?.getPlugin('history') as History
history?.undo()
const history = this.graph.getPlugin('history') as History
history.undo()
}
redo = () => {
const { graph } = this.state
const history = graph?.getPlugin('history') as History
history?.redo()
const history = this.graph.getPlugin('history') as History
history.redo()
}
render() {
return (
<div className="x6-graph-wrap">
<div ref={this.refContainer} className="x6-graph" />
<button onClick={this.enablePlugins}>enable</button>
<button onClick={this.disablePlugins}>disable</button>
<button onClick={this.undo}>undo</button>
<button onClick={this.redo}>redo</button>
<Button onClick={this.enablePlugins}>enable</Button>
<Button onClick={this.disablePlugins}>disable</Button>
<Button onClick={this.undo}>undo</Button>
<Button onClick={this.redo}>redo</Button>
</div>
)
}

View File

@ -2,13 +2,12 @@ import React from 'react'
import { Graph } from '@antv/x6'
import { Keyboard } from '@antv/x6-plugin-keyboard'
import { Selection } from '@antv/x6-plugin-selection'
import { Button } from 'antd'
import '../index.less'
export default class Example extends React.Component<
{},
{ graph: Graph | undefined }
> {
export default class Example extends React.Component {
private container: HTMLDivElement
private graph: Graph
componentDidMount() {
const graph = new Graph({
@ -18,10 +17,8 @@ export default class Example extends React.Component<
grid: true,
})
this.setState({ graph })
const selection = new Selection({ enabled: true })
const keyboard = new Keyboard({ enabled: true })
const selection = new Selection()
const keyboard = new Keyboard()
graph.use(selection)
graph.use(keyboard)
@ -52,6 +49,8 @@ export default class Example extends React.Component<
keyboard.bindKey('backspace', () => {
graph.removeCells(selection.getSelectedCells())
})
this.graph = graph
}
refContainer = (container: HTMLDivElement) => {
@ -59,21 +58,19 @@ export default class Example extends React.Component<
}
enablePlugins = () => {
const { graph } = this.state
graph.enablePlugins('keyboard')
this.graph.enablePlugins('keyboard')
}
disablePlugins = () => {
const { graph } = this.state
graph.disablePlugins('keyboard')
this.graph.disablePlugins('keyboard')
}
render() {
return (
<div className="x6-graph-wrap">
<div ref={this.refContainer} className="x6-graph" />
<button onClick={this.enablePlugins}>enable</button>
<button onClick={this.disablePlugins}>disable</button>
<Button onClick={this.enablePlugins}>enable</Button>
<Button onClick={this.disablePlugins}>disable</Button>
</div>
)
}

View File

@ -0,0 +1,25 @@
.minimap-app {
position: relative;
padding: 0;
font-family: sans-serif;
.app-btns {
margin-bottom: 8px;
}
.app-minimap {
position: absolute;
bottom: 0;
left: 620px;
width: 200px;
height: 150px;
}
.x6-widget-minimap-viewport {
border: 2px solid #8f8f8f;
}
.x6-widget-minimap-viewport-zoom {
border: 2px solid #8f8f8f;
}
}

View File

@ -0,0 +1,168 @@
import * as React from 'react'
import { Graph } from '@antv/x6'
import { MiniMap } from '@antv/x6-plugin-minimap'
import { Scroller } from '@antv/x6-plugin-scroller'
import { Radio } from 'antd'
import { SimpleNodeView } from './simple-view'
import './index.less'
const options = [
{ label: '简单视图', value: 'simple' },
{ label: '详细视图', value: 'detailed' },
]
export default class Example extends React.Component {
private container: HTMLDivElement
private minimapContainer: HTMLDivElement
private graph: Graph
componentDidMount() {
this.graph = new Graph({
container: this.container,
width: 600,
height: 320,
background: {
color: '#F2F7FA',
},
})
this.graph.use(
new Scroller({
pageVisible: true,
pageBreak: false,
pannable: true,
}),
)
this.graph.use(
new MiniMap({
container: this.minimapContainer,
width: 200,
height: 160,
padding: 10,
}),
)
this.graph.addNode({
x: 200,
y: 100,
width: 100,
height: 40,
label: 'Rect',
attrs: {
body: {
stroke: '#8f8f8f',
strokeWidth: 1,
fill: '#fff',
rx: 6,
ry: 6,
},
},
})
const source = this.graph.addNode({
x: 32,
y: 32,
width: 100,
height: 40,
label: 'Hello',
attrs: {
body: {
stroke: '#8f8f8f',
strokeWidth: 1,
fill: '#fff',
rx: 6,
ry: 6,
},
},
})
const target = this.graph.addNode({
shape: 'circle',
x: 160,
y: 180,
width: 60,
height: 60,
label: 'World',
attrs: {
body: {
stroke: '#8f8f8f',
strokeWidth: 1,
fill: '#fff',
},
},
})
this.graph.addEdge({
source,
target,
attrs: {
line: {
stroke: '#8f8f8f',
strokeWidth: 1,
},
},
})
}
onMinimapViewChange = (val: string) => {
this.graph.disposePlugins('minimap')
if (val === 'simple') {
this.graph.use(
new MiniMap({
container: this.minimapContainer,
width: 200,
height: 160,
padding: 10,
graphOptions: {
createCellView(cell) {
// 可以返回三种类型数据
// 1. null: 不渲染
// 2. undefined: 使用 X6 默认渲染方式
// 3. CellView: 自定义渲染
if (cell.isEdge()) {
return null
}
if (cell.isNode()) {
return SimpleNodeView
}
},
},
}),
)
} else {
this.graph.use(
new MiniMap({
container: this.minimapContainer,
width: 200,
height: 160,
padding: 10,
}),
)
}
}
refContainer = (container: HTMLDivElement) => {
this.container = container
}
refMiniMapContainer = (container: HTMLDivElement) => {
this.minimapContainer = container
}
render() {
return (
<div className="minimap-app">
<div className="app-btns">
<Radio.Group
options={options}
onChange={(e) => this.onMinimapViewChange(e.target.value)}
defaultValue={'detailed'}
optionType="button"
/>
</div>
<div className="app-content" ref={this.refContainer} />
<div className="app-minimap" ref={this.refMiniMapContainer} />
</div>
)
}
}

View File

@ -0,0 +1,20 @@
import { NodeView } from '@antv/x6'
export class SimpleNodeView extends NodeView {
protected renderMarkup() {
return this.renderJSONMarkup({
tagName: 'rect',
selector: 'body',
})
}
update() {
super.update({
body: {
refWidth: '100%',
refHeight: '100%',
fill: '#8f8f8f',
},
})
}
}

View File

@ -26,7 +26,7 @@ export default class Example extends React.Component {
grid: true,
})
this.scroller = new Scroller({ enabled: true })
this.scroller = new Scroller()
this.graph2.use(this.scroller)
const data = [

View File

@ -36,7 +36,6 @@ export default class Example extends React.Component {
})
this.scroller = new Scroller({
enabled: true,
pageVisible: true,
pageBreak: true,
pannable: {
@ -45,7 +44,6 @@ export default class Example extends React.Component {
},
})
this.selection = new Selection({
enabled: true,
rubberband: true,
modifiers: 'shift',
})

View File

@ -15,11 +15,8 @@ export default class Example extends React.Component {
grid: true,
})
const keyboard = new Keyboard({
enabled: true,
})
const keyboard = new Keyboard()
const selection = new Selection({
enabled: true,
rubberband: true,
multiple: true,
strict: true,

View File

@ -15,7 +15,6 @@ export default class Example extends React.Component {
})
const snapline = new Snapline({
enabled: true,
sharp: true,
})
graph.use(snapline)

View File

@ -24,9 +24,7 @@ export default class Example extends React.Component<
grid: true,
})
this.history = new History({
enabled: true,
})
this.history = new History()
this.history.on('change', () => {
this.setState({
canRedo: this.history.canRedo(),

View File

@ -1,6 +1,7 @@
import React from 'react'
import { Graph } from '@antv/x6'
import data from './data'
import { Button } from 'antd'
import './index.less'
import { register } from '@antv/x6-react-shape'
@ -138,7 +139,7 @@ export default class Canvas extends React.Component {
return (
<div className="x6-graph-wrap">
<div ref={this.refContainer} className="x6-graph" />
<button id="add-btn">add</button>
<Button id="add-btn">add</Button>
</div>
)
}

View File

@ -97,6 +97,7 @@
"@rollup/plugin-node-resolve": "^15.0.1",
"@rollup/plugin-replace": "^5.0.1",
"@rollup/plugin-typescript": "^10.0.1",
"@rollup/plugin-terser": "^0.2.0",
"@semantic-release-monorepo/cli": "^2.1.2",
"@semantic-release/changelog": "^6.0.2",
"@semantic-release/git": "^10.0.1",
@ -109,6 +110,7 @@
"boxen": "^7.0.0",
"colors": "^1.4.0",
"coveralls": "^3.1.1",
"cross-spawn": "^7.0.3",
"eslint": "^8.29.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-config-prettier": "^8.3.0",
@ -160,11 +162,7 @@
"ts-node": "^10.2.1",
"tslib": "^2.4.1",
"turbo": "^1.6.3",
"typescript": "^4.9.3",
"cross-spawn": "^7.0.3"
},
"devDependencies": {
"@rollup/plugin-terser": "^0.2.0"
"typescript": "^4.9.3"
},
"engines": {
"pnpm": ">=7"

View File

@ -13,12 +13,12 @@
styleUrls: ['./node.component.scss'],
})
export class NodeComponent implements AfterViewInit, OnChanges {
@Input() value: string;
@Input() value: string
}
```
```ts
import { register } from "@antv/x6-angular-shape";
import { register } from '@antv/x6-angular-shape'
@Component({
selector: 'app-root',
@ -33,7 +33,7 @@ export class AppComponent implements AfterViewInit {
height: 20,
content: NodeComponent,
injector: this.injector,
});
})
this.graph.addNode({
shape: 'custom-angular-component-node',
@ -45,10 +45,9 @@ export class AppComponent implements AfterViewInit {
value: '糟糕糟糕 Oh my god',
},
},
});
})
}
}
```
### TemplateRef 渲染
@ -62,7 +61,7 @@ export class AppComponent implements AfterViewInit {
```
```ts
import { register } from "@antv/x6-angular-shape";
import { register } from '@antv/x6-angular-shape'
@Component({
selector: 'app-root',
@ -70,7 +69,7 @@ import { register } from "@antv/x6-angular-shape";
styleUrls: ['./app.component.scss'],
})
export class AppComponent implements AfterViewInit {
@ViewChild('template') template: TemplateRef<{}>;
@ViewChild('template') template: TemplateRef<{}>
ngAfterViewInit(): void {
register({
@ -79,7 +78,7 @@ export class AppComponent implements AfterViewInit {
height: 20,
content: this.template,
injector: this.injector,
});
})
this.graph.addNode({
shape: 'custom-angular-template-node',
@ -90,47 +89,48 @@ export class AppComponent implements AfterViewInit {
value: '魔法怎么失灵啦',
},
},
});
})
}
}
```
## 更新节点
无论是使用 Component 还是 TemplateRef, 都是一样的更新方式.
```ts
node.setData({
ngArguments: {
value: '晚风中闪过 几帧从前啊',
},
});
})
```
## 有 demo 吗?
有的, 因为X6渲染节点部分与框架是解耦的. 因此 `x6-angular-shape` 包并非是直接在源代码里改的, 而是在一个单独的Angular环境中开发的. 该 demo 还提供了多种节点类型的性能测试, 详情请参考[Eve-Sama/x6-angular-shape](https://github.com/Eve-Sama/x6-angular-shape)、[X6G6的性能对比, 以及X6多节点类型下的FPS临界点讨论](https://github.com/antvis/X6/issues/3266)
有的, 因为 X6 渲染节点部分与框架是解耦的. 因此 `x6-angular-shape` 包并非是直接在源代码里改的, 而是在一个单独的 Angular 环境中开发的. 该 demo 还提供了多种节点类型的性能测试, 详情请参考[Eve-Sama/x6-angular-shape](https://github.com/Eve-Sama/x6-angular-shape)、[X6G6 的性能对比, 以及 X6 多节点类型下的 FPS 临界点讨论](https://github.com/antvis/X6/issues/3266)
## FAQ
### 为什么输入属性不能直接放在 data 中而需要放在 ngArguments 中? 且为什么不叫 ngInput?
因为并非所有 `node.data` 中的属性都是输入属性, 所以遍历 `data` 中的所有属性进行赋值是不合适的. 至于为什么叫 `ngArguments` 主要是有两点考虑.
- 1.x版本中已经这么用了, 沿用该API可以降低用户升级成本
- `Input` 的概念其实是来自 `Component`, 而 `TemplateRef` 中是 `context`, 在二者的基础上抽象一个 `Arguments` 的概念更通用些
### 2.x版本的 x6-angular-shape 相比较1.x版本有什么新特性吗?
- 1.x 版本中已经这么用了, 沿用该 API 可以降低用户升级成本
- `Input` 的概念其实是来自 `Component`, 而 `TemplateRef` 中是 `context`, 在二者的基础上抽象一个 `Arguments` 的概念更通用些
### 2.x 版本的 x6-angular-shape 相比较 1.x 版本有什么新特性吗?
实现思路其实和之前是差不多的. 但是确实有几个点值得一提.
#### demo更聚焦
#### demo 更聚焦
1.x版本的 demo 除了渲染组件外, 还写了连线、清除等一系列案例. 看似扩展, 实则眼花缭乱. 作为 `x6-angular-shape`的 demo, 2.x版本更加聚焦, 更加聚焦于shape的使用与性能测试等, 与插件无关的内容请查看X6官网.
1.x 版本的 demo 除了渲染组件外, 还写了连线、清除等一系列案例. 看似扩展, 实则眼花缭乱. 作为 `x6-angular-shape`的 demo, 2.x 版本更加聚焦, 更加聚焦于 shape 的使用与性能测试等, 与插件无关的内容请查看 X6 官网.
#### 功能更稳定
在1.x版本中, 虽然实现了功能, 但是使用场景的思考不够全面. 比如`ngArguments`的变化, 对 `TemplateRef`的场景并不生效. 虽然对`Component`生效但是无法触发`ngOnChanges`. 而在新版本中, 这些问题都将不复存在.
1.x 版本中, 虽然实现了功能, 但是使用场景的思考不够全面. 比如`ngArguments`的变化, 对 `TemplateRef`的场景并不生效. 虽然对`Component`生效但是无法触发`ngOnChanges`. 而在新版本中, 这些问题都将不复存在.
### 版本要求
你的Angular版本至少在14及以上才可以. 14以下需要用 hack 的方式实现一些特性, 比较麻烦. 暂时不提供, 如有需要可提issue, 我再专门介绍下如何实现.
你的 Angular 版本至少在 14 及以上才可以. 14 以下需要用 hack 的方式实现一些特性, 比较麻烦. 暂时不提供, 如有需要可提 issue, 我再专门介绍下如何实现.

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-angular-shape",
"version": "2.0.0",
"version": "2.0.1",
"description": "X6 shape for rendering angular components.",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -1,43 +1,37 @@
## @antv/x6-common [2.0.10](https://github.com/antvis/x6/compare/@antv/x6-common@2.0.9...@antv/x6-common@2.0.10) (2023-02-24)
### Bug Fixes
* add textLength & lengthAdjust to CASE_SENSITIVE_ATTR ([#3281](https://github.com/antvis/x6/issues/3281)) ([76fb1ac](https://github.com/antvis/x6/commit/76fb1acf74b0f1c308f7c824d02c12244b7ac8f3))
- add textLength & lengthAdjust to CASE_SENSITIVE_ATTR ([#3281](https://github.com/antvis/x6/issues/3281)) ([76fb1ac](https://github.com/antvis/x6/commit/76fb1acf74b0f1c308f7c824d02c12244b7ac8f3))
## @antv/x6-common [2.0.8](https://github.com/antvis/x6/compare/@antv/x6-common@2.0.7...@antv/x6-common@2.0.8) (2023-02-18)
### Bug Fixes
* fix typo for dom event handlers ([#3255](https://github.com/antvis/x6/issues/3255)) ([9b4fa86](https://github.com/antvis/x6/commit/9b4fa86daa587fe8818f3615bc1e40738a0f2319))
- fix typo for dom event handlers ([#3255](https://github.com/antvis/x6/issues/3255)) ([9b4fa86](https://github.com/antvis/x6/commit/9b4fa86daa587fe8818f3615bc1e40738a0f2319))
## @antv/x6-common [2.0.6](https://github.com/antvis/x6/compare/@antv/x6-common@2.0.5...@antv/x6-common@2.0.6) (2023-01-31)
### Bug Fixes
* fix index error for priorityQueue ([#3179](https://github.com/antvis/x6/issues/3179)) ([d64150b](https://github.com/antvis/x6/commit/d64150bfadf10fe21f44734a0267261260b8c53b))
- fix index error for priorityQueue ([#3179](https://github.com/antvis/x6/issues/3179)) ([d64150b](https://github.com/antvis/x6/commit/d64150bfadf10fe21f44734a0267261260b8c53b))
## @antv/x6-common [2.0.5](https://github.com/antvis/x6/compare/@antv/x6-common@2.0.4...@antv/x6-common@2.0.5) (2023-01-18)
### Bug Fixes
* optimize css loader ([#3156](https://github.com/antvis/x6/issues/3156)) ([9c48ad8](https://github.com/antvis/x6/commit/9c48ad8dfc99e623a57855295d07c35be5483073))
- optimize css loader ([#3156](https://github.com/antvis/x6/issues/3156)) ([9c48ad8](https://github.com/antvis/x6/commit/9c48ad8dfc99e623a57855295d07c35be5483073))
## @antv/x6-common [2.0.4](https://github.com/antvis/x6/compare/@antv/x6-common@2.0.3...@antv/x6-common@2.0.4) (2022-12-20)
### Bug Fixes
* fix window incompatibility problem ([#3070](https://github.com/antvis/x6/issues/3070)) ([d8e1e63](https://github.com/antvis/x6/commit/d8e1e637d8027b9494cd26efc87815d74bd51366))
- fix window incompatibility problem ([#3070](https://github.com/antvis/x6/issues/3070)) ([d8e1e63](https://github.com/antvis/x6/commit/d8e1e637d8027b9494cd26efc87815d74bd51366))
## @antv/x6-common [2.0.1](https://github.com/antvis/x6/compare/@antv/x6-common@2.0.0...@antv/x6-common@2.0.1) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-common [2.0.1](https://github.com/antvis/x6/compare/@antv/x6-common@2.0.0...@antv/x6-common@2.0.1) (2022-11-24)

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-common",
"version": "2.0.11",
"version": "2.0.13",
"description": "Basic toolkit for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -62,7 +62,7 @@ export class EventObject<
}
}
preventDefault() {
preventDefault = () => {
const e = this.originalEvent
this.isDefaultPrevented = Util.returnTrue
@ -72,7 +72,7 @@ export class EventObject<
}
}
stopPropagation() {
stopPropagation = () => {
const e = this.originalEvent
this.isPropagationStopped = Util.returnTrue
@ -82,7 +82,7 @@ export class EventObject<
}
}
stopImmediatePropagation() {
stopImmediatePropagation = () => {
const e = this.originalEvent
this.isImmediatePropagationStopped = Util.returnTrue

View File

@ -198,12 +198,16 @@ export function text(
const autoLineHeight = defaultLineHeight === 'auto'
const lineHeight = autoLineHeight ? '1.5em' : defaultLineHeight || '1em'
let needEmptyElem = true
const childs = elem.children
if (childs.length === 1 && childs[0].tagName.toUpperCase() === 'TITLE') {
needEmptyElem = false
let needEmpty = true
const childNodes = elem.childNodes
if (childNodes.length === 1) {
const node = childNodes[0] as any
if (node && node.tagName.toUpperCase() === 'TITLE') {
needEmpty = false
}
}
if (needEmptyElem) {
if (needEmpty) {
empty(elem)
}

View File

@ -1,9 +1,15 @@
# X6 Devtool
> A devtool for @antv/x6 in chrome, it's still WIP, you can load it in unpack way;
## Quick Start
### Install from chrome web store
![image](https://user-images.githubusercontent.com/1826685/238003455-d341f598-1b35-4d8c-bb7c-0320cad6a4cb.png)
### Import unpacked plugin
![image](https://user-images.githubusercontent.com/15213473/150081309-61f9c451-c35e-4dab-a23c-ed5e425e7ec5.png)
1. Open the Extension Management page by navigating to chrome://extensions.
@ -16,34 +22,25 @@
```javascript
// init window hook
window.__x6_instances__ = [];
window.__x6_instances__ = []
var graph = new Graph({...blablabla});
window.__x6_instances__.push(graph);
var graph = new Graph({ ...blablabla })
window.__x6_instances__.push(graph)
```
### Using devtool
After these steps, the tab 'AntV X6' should show in devtools' tab, select it and choose a canvas
![image](https://user-images.githubusercontent.com/1826685/223881189-bf99f2ad-5158-4c39-8d16-018a287ac2fe.png)
![image](https://user-images.githubusercontent.com/1826685/238013980-2d6018f8-7d85-473c-a043-98b1f03b6674.png)
## Features
### Inspect Element in Graph
![image](https://user-images.githubusercontent.com/1826685/223881189-bf99f2ad-5158-4c39-8d16-018a287ac2fe.png)
![image](https://user-images.githubusercontent.com/1826685/238014156-e65ec2b0-f719-410e-9a10-89cdb836acde.png)
### View and Modify Attributes of Element
![image](https://user-images.githubusercontent.com/1826685/223881189-bf99f2ad-5158-4c39-8d16-018a287ac2fe.png)
### Using select element directly in graph
![image](https://user-images.githubusercontent.com/1826685/223881189-bf99f2ad-5158-4c39-8d16-018a287ac2fe.png)
![image](https://user-images.githubusercontent.com/1826685/238014353-124feb8e-2049-499d-a13d-3d26f485bab6.png)

View File

@ -3,9 +3,9 @@
"description": "devtool for x6 graph",
"version": "0.0.1",
"devtools_page": "x6_devtools.html",
"minimum_chrome_version": "49",
"manifest_version": 2,
"permissions": ["file:///*", "http://*/*", "https://*/*"],
"minimum_chrome_version": "88",
"manifest_version": 3,
"host_permissions": ["file:///*", "http://*/*", "https://*/*"],
"icons": {
"16": "icons/16.png",
"32": "icons/32.png",
@ -13,7 +13,11 @@
"128": "icons/128.png"
},
"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'",
"web_accessible_resources": ["main.html", "panel.html", "script/backend.js"],
"browser_action": {}
"web_accessible_resources": [
{
"resources": ["main.html", "panel.html", "script/backend.js"],
"matches": ["<all_urls>"]
}
],
"action": {}
}

File diff suppressed because one or more lines are too long

View File

@ -2,10 +2,9 @@
## @antv/x6-geometry [2.0.3](https://github.com/antvis/x6/compare/@antv/x6-geometry@2.0.2...@antv/x6-geometry@2.0.3) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-geometry [2.0.2](https://github.com/antvis/x6/compare/@antv/x6-geometry@2.0.1...@antv/x6-geometry@2.0.2) (2022-11-25)

View File

@ -2,15 +2,6 @@
> Some useful geometry operations.
<a href="/LICENSE"><img src="https://img.shields.io/github/license/antvis/x6?style=flat-square" alt="MIT License"></a>
<a href="https://www.typescriptlang.org"><img alt="Language" src="https://img.shields.io/badge/language-TypeScript-blue.svg?style=flat-square"></a>
<a href="https://github.com/antvis/x6/pulls"><img alt="PRs Welcome" src="https://img.shields.io/badge/PRs-Welcome-brightgreen.svg?style=flat-square"></a>
<a href="https://x6.antv.antgroup.com"><img alt="website" src="https://img.shields.io/static/v1?label=&labelColor=505050&message=website&color=0076D6&style=flat-square&logo=google-chrome&logoColor=0076D6"></a>
<a href="https://github.com/antvis/X6/actions/workflows/ci.yml"><img alt="build" src="https://img.shields.io/github/workflow/status/antvis/x6/%F0%9F%91%B7%E3%80%80CI/master?logo=github&style=flat-square"></a>
<a href="https://app.codecov.io/gh/antvis/x6"><img alt="coverage" src="https://img.shields.io/codecov/c/gh/antvis/x6?logo=codecov&flag=x6-geometry&style=flat-square&token=15CO54WYUV"></a>
<a href="https://lgtm.com/projects/g/antvis/x6/context:javascript"><img alt="Language grade: JavaScript" src="https://img.shields.io/lgtm/grade/javascript/g/antvis/x6.svg?logo=lgtm&style=flat-square"></a>
<a href="/LICENSE"><img src="https://img.shields.io/github/license/antvis/x6?style=flat-square" alt="MIT License"></a> <a href="https://www.typescriptlang.org"><img alt="Language" src="https://img.shields.io/badge/language-TypeScript-blue.svg?style=flat-square"></a> <a href="https://github.com/antvis/x6/pulls"><img alt="PRs Welcome" src="https://img.shields.io/badge/PRs-Welcome-brightgreen.svg?style=flat-square"></a> <a href="https://x6.antv.antgroup.com"><img alt="website" src="https://img.shields.io/static/v1?label=&labelColor=505050&message=website&color=0076D6&style=flat-square&logo=google-chrome&logoColor=0076D6"></a> <a href="https://github.com/antvis/X6/actions/workflows/ci.yml"><img alt="build" src="https://img.shields.io/github/workflow/status/antvis/x6/%F0%9F%91%B7%E3%80%80CI/master?logo=github&style=flat-square"></a> <a href="https://app.codecov.io/gh/antvis/x6"><img alt="coverage" src="https://img.shields.io/codecov/c/gh/antvis/x6?logo=codecov&flag=x6-geometry&style=flat-square&token=15CO54WYUV"></a> <a href="https://lgtm.com/projects/g/antvis/x6/context:javascript"><img alt="Language grade: JavaScript" src="https://img.shields.io/lgtm/grade/javascript/g/antvis/x6.svg?logo=lgtm&style=flat-square"></a>
<a href="https://www.npmjs.com/package/@antv/x6-geometry"><img alt="NPM Package" src="https://img.shields.io/npm/v/@antv/x6-geometry.svg?style=flat-square"></a>
<a href="https://www.npmjs.com/package/@antv/x6-geometry"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/@antv/x6-geometry?logo=npm&style=flat-square"></a>
<a href="https://david-dm.org/antvis/x6?path=packages/x6-geometry"><img alt="Dependency Status" src="https://david-dm.org/antvis/x6.svg?style=flat-square&path=packages/x6-geometry"></a>
<a href="https://david-dm.org/antvis/x6?type=dev&path=packages/x6-geometry"><img alt="devDependencies Status" src="https://david-dm.org/antvis/x6/dev-status.svg?style=flat-square&path=packages/x6-geometry" ></a>
<a href="https://www.npmjs.com/package/@antv/x6-geometry"><img alt="NPM Package" src="https://img.shields.io/npm/v/@antv/x6-geometry.svg?style=flat-square"></a> <a href="https://www.npmjs.com/package/@antv/x6-geometry"><img alt="NPM Downloads" src="https://img.shields.io/npm/dm/@antv/x6-geometry?logo=npm&style=flat-square"></a> <a href="https://david-dm.org/antvis/x6?path=packages/x6-geometry"><img alt="Dependency Status" src="https://david-dm.org/antvis/x6.svg?style=flat-square&path=packages/x6-geometry"></a> <a href="https://david-dm.org/antvis/x6?type=dev&path=packages/x6-geometry"><img alt="devDependencies Status" src="https://david-dm.org/antvis/x6/dev-status.svg?style=flat-square&path=packages/x6-geometry" ></a>

View File

@ -1,5 +1,5 @@
{
"version": "2.0.4",
"version": "2.0.5",
"name": "@antv/x6-geometry",
"description": "Geometry operations for X6",
"main": "lib/index.js",

View File

@ -1,22 +1,19 @@
## @antv/x6-plugin-clipboard [2.1.3](https://github.com/antvis/x6/compare/@antv/x6-plugin-clipboard@2.1.2...@antv/x6-plugin-clipboard@2.1.3) (2022-11-25)
### Bug Fixes
* broken file ([d6df2d5](https://github.com/antvis/x6/commit/d6df2d59811dc18791208af36b452e11e6391f3b))
- broken file ([d6df2d5](https://github.com/antvis/x6/commit/d6df2d59811dc18791208af36b452e11e6391f3b))
## @antv/x6-plugin-clipboard [2.1.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-clipboard@2.1.1...@antv/x6-plugin-clipboard@2.1.2) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-clipboard [2.1.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-clipboard@2.1.0...@antv/x6-plugin-clipboard@2.1.1) (2022-11-25)
# @antv/x6-plugin-clipboard [2.1.0](https://github.com/antvis/x6/compare/@antv/x6-plugin-clipboard@2.0.0...@antv/x6-plugin-clipboard@2.1.0) (2022-11-24)
### Features
* attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))
- attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-clipboard",
"version": "2.1.3",
"version": "2.1.6",
"description": "clipboard plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -1,19 +1,27 @@
import { Cell, Graph, IDisablable, Basecoat } from '@antv/x6'
import { Cell, Graph, Basecoat } from '@antv/x6'
import { ClipboardImpl } from './clipboard'
import './api'
export class Clipboard
extends Basecoat<Clipboard.EventArgs>
implements IDisablable
implements Graph.Plugin
{
public name = 'clipboard'
private clipboardImpl: ClipboardImpl
private graph: Graph
public options: Clipboard.Options
public name = 'clipboard'
constructor(options: Clipboard.Options = { enabled: true }) {
get disabled() {
return this.options.enabled !== true
}
get cells() {
return this.clipboardImpl.cells
}
constructor(options: Clipboard.Options = {}) {
super()
this.options = options
this.options = { enabled: true, ...options }
}
init(graph: Graph) {
@ -108,19 +116,11 @@ export class Clipboard
// #endregion
get disabled() {
return this.options.enabled !== true
}
protected get commonOptions() {
const { enabled, ...others } = this.options
return others
}
protected get cells() {
return this.clipboardImpl.cells
}
protected notify<K extends keyof Clipboard.EventArgs>(
name: K,
args: Clipboard.EventArgs[K],

View File

@ -1,22 +1,19 @@
## @antv/x6-plugin-dnd [2.0.4](https://github.com/antvis/x6/compare/@antv/x6-plugin-dnd@2.0.3...@antv/x6-plugin-dnd@2.0.4) (2023-01-13)
### Bug Fixes
* change dragging container options ([#3139](https://github.com/antvis/x6/issues/3139)) ([7b091f3](https://github.com/antvis/x6/commit/7b091f35dee147c5e7bf97577e14e11ceb7e8e3d))
- change dragging container options ([#3139](https://github.com/antvis/x6/issues/3139)) ([7b091f3](https://github.com/antvis/x6/commit/7b091f35dee147c5e7bf97577e14e11ceb7e8e3d))
## @antv/x6-plugin-dnd [2.0.3](https://github.com/antvis/x6/compare/@antv/x6-plugin-dnd@2.0.2...@antv/x6-plugin-dnd@2.0.3) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-dnd [2.0.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-dnd@2.0.1...@antv/x6-plugin-dnd@2.0.2) (2022-11-25)
## @antv/x6-plugin-dnd [2.0.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-dnd@2.0.0...@antv/x6-plugin-dnd@2.0.1) (2022-11-24)
### Bug Fixes
* export snap methods from snapline ([#2904](https://github.com/antvis/x6/issues/2904)) ([826ccdd](https://github.com/antvis/x6/commit/826ccdd9a033486ad5b90d666340e46f6c266af7))
- export snap methods from snapline ([#2904](https://github.com/antvis/x6/issues/2904)) ([826ccdd](https://github.com/antvis/x6/commit/826ccdd9a033486ad5b90d666340e46f6c266af7))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-dnd",
"version": "2.0.4",
"version": "2.0.5",
"description": "dnd plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -14,7 +14,9 @@ import {
} from '@antv/x6'
import { content } from './style/raw'
export class Dnd extends View {
export class Dnd extends View implements Graph.Plugin {
public name = 'dnd'
protected sourceNode: Node | null
protected draggingNode: Node | null
protected draggingView: NodeView | null
@ -26,9 +28,8 @@ export class Dnd extends View {
protected snapOffset: Point.PointLike | null
protected originOffset: null | { left: number; top: number }
public name = 'dnd'
public readonly options: Dnd.Options
public readonly draggingGraph: Graph
public options: Dnd.Options
public draggingGraph: Graph
protected get targetScroller() {
const target = this.options.target
@ -52,13 +53,15 @@ export class Dnd extends View {
constructor(options: Partial<Dnd.Options> & { target: Graph }) {
super()
CssLoader.ensure(this.name, content)
this.options = {
...Dnd.defaults,
...options,
} as Dnd.Options
this.init()
}
init() {
CssLoader.ensure(this.name, content)
this.container = document.createElement('div')
Dom.addClass(this.container, this.prefixClassName('widget-dnd'))

View File

@ -1,16 +1,14 @@
## @antv/x6-plugin-export [2.1.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-export@2.1.1...@antv/x6-plugin-export@2.1.2) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-export [2.1.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-export@2.1.0...@antv/x6-plugin-export@2.1.1) (2022-11-25)
# @antv/x6-plugin-export [2.1.0](https://github.com/antvis/x6/compare/@antv/x6-plugin-export@2.0.0...@antv/x6-plugin-export@2.1.0) (2022-11-24)
### Features
* add exportSVG methods ([#2906](https://github.com/antvis/x6/issues/2906)) ([847f225](https://github.com/antvis/x6/commit/847f2256326db0589ac37f1e1fa185560b61bdb7))
* attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))
- add exportSVG methods ([#2906](https://github.com/antvis/x6/issues/2906)) ([847f225](https://github.com/antvis/x6/commit/847f2256326db0589ac37f1e1fa185560b61bdb7))
- attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))

View File

@ -2,4 +2,4 @@
> TODO: description
## Usage
## Usage

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-export",
"version": "2.1.5",
"version": "2.1.6",
"description": "export plugin for X6.",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -12,22 +12,22 @@ import {
} from '@antv/x6'
import './api'
export class Export extends Basecoat<Export.EventArgs> {
private graph: Graph
export class Export extends Basecoat<Export.EventArgs> implements Graph.Plugin {
public name = 'export'
private graph: Graph
constructor() {
super()
}
init(graph: Graph) {
this.graph = graph
}
get view() {
return this.graph.view
}
init(graph: Graph) {
this.graph = graph
}
exportPNG(fileName = 'chart', options: Export.ToImageOptions = {}) {
this.toPNG((dataUri) => {
DataUri.downloadDataUri(dataUri, fileName)
@ -328,6 +328,11 @@ export class Export extends Basecoat<Export.EventArgs> {
this.trigger(name, args)
this.graph.trigger(name, args)
}
@Basecoat.dispose()
dispose(): void {
this.off()
}
}
export namespace Export {

View File

@ -1,29 +1,25 @@
# @antv/x6-plugin-history [2.2.0](https://github.com/antvis/x6/compare/@antv/x6-plugin-history@2.1.3...@antv/x6-plugin-history@2.2.0) (2023-02-17)
### Features
* history add max stack size ([#3253](https://github.com/antvis/x6/issues/3253)) ([fba5310](https://github.com/antvis/x6/commit/fba531064ad8027c451a81b60d5efd7f7314a0fa))
- history add max stack size ([#3253](https://github.com/antvis/x6/issues/3253)) ([fba5310](https://github.com/antvis/x6/commit/fba531064ad8027c451a81b60d5efd7f7314a0fa))
## @antv/x6-plugin-history [2.1.3](https://github.com/antvis/x6/compare/@antv/x6-plugin-history@2.1.2...@antv/x6-plugin-history@2.1.3) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-history [2.1.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-history@2.1.1...@antv/x6-plugin-history@2.1.2) (2022-11-25)
## @antv/x6-plugin-history [2.1.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-history@2.1.0...@antv/x6-plugin-history@2.1.1) (2022-11-24)
### Bug Fixes
* deep clone instead of shallow clone ([#2924](https://github.com/antvis/x6/issues/2924)) ([75f4297](https://github.com/antvis/x6/commit/75f42978cb0ed4c9e7c7ac141ffa29603cb27596))
- deep clone instead of shallow clone ([#2924](https://github.com/antvis/x6/issues/2924)) ([75f4297](https://github.com/antvis/x6/commit/75f42978cb0ed4c9e7c7ac141ffa29603cb27596))
# @antv/x6-plugin-history [2.1.0](https://github.com/antvis/x6/compare/@antv/x6-plugin-history@2.0.0...@antv/x6-plugin-history@2.1.0) (2022-11-24)
### Features
* attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))
- attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-history",
"version": "2.2.0",
"version": "2.2.3",
"description": "history plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -3,7 +3,6 @@ import {
ObjectExt,
FunctionExt,
Basecoat,
IDisablable,
Cell,
Model,
Graph,
@ -12,7 +11,7 @@ import './api'
export class History
extends Basecoat<History.EventArgs>
implements IDisablable
implements Graph.Plugin
{
public name = 'history'
public graph: Graph
@ -32,7 +31,7 @@ export class History
args: Model.EventArgs[T],
) => any)[] = []
constructor(options: History.Options) {
constructor(options: History.Options = {}) {
super()
const { stackSize = 0 } = options
this.stackSize = stackSize
@ -267,6 +266,14 @@ export class History
const key = data.key
if (key && cell) {
const value = revert ? data.prev[key] : data.next[key]
if (data.key === 'attrs') {
this.ensureUndefinedAttrs(
value,
revert ? data.next[key] : data.prev[key],
)
}
cell.prop(key, value, options)
}
} else {
@ -591,6 +598,30 @@ export class History
this.undoStack.push(cmd)
}
protected ensureUndefinedAttrs(
newAttrs: Record<string, any>,
oldAttrs: Record<string, any>,
) {
if (
newAttrs !== null &&
oldAttrs !== null &&
typeof newAttrs === 'object' &&
typeof oldAttrs === 'object'
) {
Object.keys(oldAttrs).forEach((key) => {
// eslint-disable-next-line no-prototype-builtins
if (!newAttrs.hasOwnProperty(key)) {
newAttrs[key] = undefined
} else if (
typeof newAttrs[key] === 'object' &&
typeof oldAttrs[key] === 'object'
) {
this.ensureUndefinedAttrs(newAttrs[key], oldAttrs[key])
}
})
}
}
@Basecoat.dispose()
dispose() {
this.validator.dispose()
@ -863,6 +894,7 @@ namespace Util {
: reservedNames
return {
enabled: true,
...options,
eventNames,
applyOptionsList: options.applyOptionsList || ['propertyPath'],

View File

@ -1,36 +1,31 @@
# @antv/x6-plugin-keyboard [2.2.0](https://github.com/antvis/x6/compare/@antv/x6-plugin-keyboard@2.1.4...@antv/x6-plugin-keyboard@2.2.0) (2023-02-06)
### Features
* keyboard support clear and custom trigger ([#3202](https://github.com/antvis/x6/issues/3202)) ([668c932](https://github.com/antvis/x6/commit/668c93242fbcebb987cccc3dcfd56982f7c66252))
- keyboard support clear and custom trigger ([#3202](https://github.com/antvis/x6/issues/3202)) ([668c932](https://github.com/antvis/x6/commit/668c93242fbcebb987cccc3dcfd56982f7c66252))
## @antv/x6-plugin-keyboard [2.1.4](https://github.com/antvis/x6/compare/@antv/x6-plugin-keyboard@2.1.3...@antv/x6-plugin-keyboard@2.1.4) (2022-11-29)
### Bug Fixes
* not trigger keyboard event whith delete key in contenteditable elem ([#2965](https://github.com/antvis/x6/issues/2965)) ([4978110](https://github.com/antvis/x6/commit/4978110b4594aee801d39c74f5c190432846eba4))
- not trigger keyboard event whith delete key in contenteditable elem ([#2965](https://github.com/antvis/x6/issues/2965)) ([4978110](https://github.com/antvis/x6/commit/4978110b4594aee801d39c74f5c190432846eba4))
## @antv/x6-plugin-keyboard [2.1.3](https://github.com/antvis/x6/compare/@antv/x6-plugin-keyboard@2.1.2...@antv/x6-plugin-keyboard@2.1.3) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-keyboard [2.1.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-keyboard@2.1.1...@antv/x6-plugin-keyboard@2.1.2) (2022-11-25)
## @antv/x6-plugin-keyboard [2.1.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-keyboard@2.1.0...@antv/x6-plugin-keyboard@2.1.1) (2022-11-25)
### Performance Improvements
* update deps ([f20127a](https://github.com/antvis/x6/commit/f20127af555d9b7beaac3a07ac308d5c0d4e53a3))
- update deps ([f20127a](https://github.com/antvis/x6/commit/f20127af555d9b7beaac3a07ac308d5c0d4e53a3))
# @antv/x6-plugin-keyboard [2.1.0](https://github.com/antvis/x6/compare/@antv/x6-plugin-keyboard@2.0.0...@antv/x6-plugin-keyboard@2.1.0) (2022-11-24)
### Features
* attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))
- attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-keyboard",
"version": "2.2.0",
"version": "2.2.1",
"description": "keyboard plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -2,14 +2,14 @@ import { Disposable, Graph } from '@antv/x6'
import { KeyboardImpl } from './keyboard'
import './api'
export class Keyboard extends Disposable {
private keyboardImpl: KeyboardImpl
export class Keyboard extends Disposable implements Graph.Plugin {
public name = 'keyboard'
private keyboardImpl: KeyboardImpl
public options: KeyboardImpl.Options
constructor(options: KeyboardImpl.Options = { enabled: true }) {
constructor(options: KeyboardImpl.Options = {}) {
super()
this.options = options
this.options = { enabled: true, ...options }
}
init(graph: Graph) {

View File

@ -1,15 +1,13 @@
## @antv/x6-plugin-minimap [2.0.3](https://github.com/antvis/x6/compare/@antv/x6-plugin-minimap@2.0.2...@antv/x6-plugin-minimap@2.0.3) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-minimap [2.0.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-minimap@2.0.1...@antv/x6-plugin-minimap@2.0.2) (2022-11-25)
## @antv/x6-plugin-minimap [2.0.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-minimap@2.0.0...@antv/x6-plugin-minimap@2.0.1) (2022-11-24)
### Bug Fixes
* add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
- add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-minimap",
"version": "2.0.3",
"version": "2.0.5",
"description": "minimap plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -1,7 +1,16 @@
import { FunctionExt, CssLoader, Dom, View, Graph, EventArgs } from '@antv/x6'
import {
FunctionExt,
CssLoader,
Dom,
View,
Graph,
EventArgs,
Model,
} from '@antv/x6'
import { content } from './style/raw'
export class MiniMap extends View {
export class MiniMap extends View implements Graph.Plugin {
public name = 'minimap'
private graph: Graph
public readonly options: MiniMap.Options
public container: HTMLDivElement
@ -14,7 +23,6 @@ export class MiniMap extends View {
// Marks whether targetGraph is being transformed or scaled
// If yes we update updateViewport only
private targetGraphTransforming: boolean
public name = 'minimap'
protected get scroller() {
return this.graph.getPlugin<any>('scroller')
@ -129,8 +137,8 @@ export class MiniMap extends View {
}
protected onRemove() {
this.targetGraph.view.remove()
this.stopListening()
this.targetGraph.model = new Model()
this.targetGraph.dispose()
}

View File

@ -1,16 +1,14 @@
## @antv/x6-plugin-scroller [2.0.3](https://github.com/antvis/x6/compare/@antv/x6-plugin-scroller@2.0.2...@antv/x6-plugin-scroller@2.0.3) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-scroller [2.0.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-scroller@2.0.1...@antv/x6-plugin-scroller@2.0.2) (2022-11-25)
## @antv/x6-plugin-scroller [2.0.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-scroller@2.0.0...@antv/x6-plugin-scroller@2.0.1) (2022-11-24)
### Bug Fixes
* add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
* resize graph when scale scroller ([#2903](https://github.com/antvis/x6/issues/2903)) ([cee4aa4](https://github.com/antvis/x6/commit/cee4aa4e53b2821ed11d5602fccdb36625957c72))
- add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
- resize graph when scale scroller ([#2903](https://github.com/antvis/x6/issues/2903)) ([cee4aa4](https://github.com/antvis/x6/commit/cee4aa4e53b2821ed11d5602fccdb36625957c72))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-scroller",
"version": "2.0.8",
"version": "2.0.9",
"description": "scroller plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -15,12 +15,16 @@ import { ScrollerImpl } from './scroller'
import { content } from './style/raw'
import './api'
export class Scroller extends Basecoat<Scroller.EventArgs> {
export class Scroller
extends Basecoat<Scroller.EventArgs>
implements Graph.Plugin
{
public name = 'scroller'
public options: Scroller.Options
private graph: Graph
private scrollerImpl: ScrollerImpl
public name = 'scroller'
public get pannable() {
get pannable() {
if (this.options) {
if (typeof this.options.pannable === 'object') {
return this.options.pannable.enabled
@ -31,18 +35,23 @@ export class Scroller extends Basecoat<Scroller.EventArgs> {
return false
}
public get container() {
get container() {
return this.scrollerImpl.container
}
constructor(public options: Scroller.Options) {
constructor(options: Scroller.Options = {}) {
super()
this.options = options
CssLoader.ensure(this.name, content)
}
public init(graph: Graph) {
this.graph = graph
const options = ScrollerImpl.getOptions({ ...this.options, graph })
const options = ScrollerImpl.getOptions({
enabled: true,
...this.options,
graph,
})
this.options = options
this.scrollerImpl = new ScrollerImpl(options)
this.setup()

View File

@ -1,34 +1,29 @@
## @antv/x6-plugin-selection [2.1.4](https://github.com/antvis/x6/compare/@antv/x6-plugin-selection@2.1.3...@antv/x6-plugin-selection@2.1.4) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-selection [2.1.3](https://github.com/antvis/x6/compare/@antv/x6-plugin-selection@2.1.2...@antv/x6-plugin-selection@2.1.3) (2022-11-25)
## @antv/x6-plugin-selection [2.1.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-selection@2.1.1...@antv/x6-plugin-selection@2.1.2) (2022-11-24)
### Bug Fixes
* support antd5 in react components ([#2933](https://github.com/antvis/x6/issues/2933)) ([2ecc213](https://github.com/antvis/x6/commit/2ecc213094250b476b533b444c0f3716f88b7987))
- support antd5 in react components ([#2933](https://github.com/antvis/x6/issues/2933)) ([2ecc213](https://github.com/antvis/x6/commit/2ecc213094250b476b533b444c0f3716f88b7987))
## @antv/x6-plugin-selection [2.1.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-selection@2.1.0...@antv/x6-plugin-selection@2.1.1) (2022-11-24)
### Bug Fixes
* modify the semantics of filter ([#2927](https://github.com/antvis/x6/issues/2927)) ([bc261fb](https://github.com/antvis/x6/commit/bc261fb9929aa0b4d3fa4194bcc780ea701b029e))
- modify the semantics of filter ([#2927](https://github.com/antvis/x6/issues/2927)) ([bc261fb](https://github.com/antvis/x6/commit/bc261fb9929aa0b4d3fa4194bcc780ea701b029e))
# @antv/x6-plugin-selection [2.1.0](https://github.com/antvis/x6/compare/@antv/x6-plugin-selection@2.0.0...@antv/x6-plugin-selection@2.1.0) (2022-11-24)
### Bug Fixes
* add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
- add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
### Features
* attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))
- attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-selection",
"version": "2.1.5",
"version": "2.1.7",
"description": "selection plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -2,6 +2,8 @@
.@{selection-prefix-cls} {
position: absolute;
top: 0;
left: 0;
display: none;
width: 0;
height: 0;

View File

@ -12,33 +12,41 @@ import { SelectionImpl } from './selection'
import { content } from './style/raw'
import './api'
export class Selection extends Basecoat<SelectionImpl.EventArgs> {
export class Selection
extends Basecoat<SelectionImpl.EventArgs>
implements Graph.Plugin
{
public name = 'selection'
private graph: Graph
private selectionImpl: SelectionImpl
private readonly options: Selection.Options
private movedMap = new WeakMap<Cell, boolean>()
private unselectMap = new WeakMap<Cell, boolean>()
public name = 'selection'
private get rubberbandDisabled() {
get rubberbandDisabled() {
return this.options.enabled !== true || this.options.rubberband !== true
}
public get disabled() {
get disabled() {
return this.options.enabled !== true
}
public get length() {
get length() {
return this.selectionImpl.length
}
public get cells() {
get cells() {
return this.selectionImpl.cells
}
constructor(options: Selection.Options = { enabled: true }) {
constructor(options: Selection.Options = {}) {
super()
this.options = ObjectExt.merge({}, Selection.defaultOptions, options)
this.options = ObjectExt.merge(
{ enabled: true },
Selection.defaultOptions,
options,
)
CssLoader.ensure(this.name, content)
}

View File

@ -1,35 +1,30 @@
## @antv/x6-plugin-snapline [2.1.4](https://github.com/antvis/x6/compare/@antv/x6-plugin-snapline@2.1.3...@antv/x6-plugin-snapline@2.1.4) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-snapline [2.1.3](https://github.com/antvis/x6/compare/@antv/x6-plugin-snapline@2.1.2...@antv/x6-plugin-snapline@2.1.3) (2022-11-25)
## @antv/x6-plugin-snapline [2.1.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-snapline@2.1.1...@antv/x6-plugin-snapline@2.1.2) (2022-11-24)
### Bug Fixes
* updae react-resize-detector version ([#2930](https://github.com/antvis/x6/issues/2930)) ([d6ae519](https://github.com/antvis/x6/commit/d6ae5199c00be6429a828f537b194adddd2b6aeb))
- updae react-resize-detector version ([#2930](https://github.com/antvis/x6/issues/2930)) ([d6ae519](https://github.com/antvis/x6/commit/d6ae5199c00be6429a828f537b194adddd2b6aeb))
## @antv/x6-plugin-snapline [2.1.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-snapline@2.1.0...@antv/x6-plugin-snapline@2.1.1) (2022-11-24)
### Bug Fixes
* modify the semantics of filter ([#2927](https://github.com/antvis/x6/issues/2927)) ([bc261fb](https://github.com/antvis/x6/commit/bc261fb9929aa0b4d3fa4194bcc780ea701b029e))
- modify the semantics of filter ([#2927](https://github.com/antvis/x6/issues/2927)) ([bc261fb](https://github.com/antvis/x6/commit/bc261fb9929aa0b4d3fa4194bcc780ea701b029e))
# @antv/x6-plugin-snapline [2.1.0](https://github.com/antvis/x6/compare/@antv/x6-plugin-snapline@2.0.0...@antv/x6-plugin-snapline@2.1.0) (2022-11-24)
### Bug Fixes
* add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
* export snap methods from snapline ([#2904](https://github.com/antvis/x6/issues/2904)) ([826ccdd](https://github.com/antvis/x6/commit/826ccdd9a033486ad5b90d666340e46f6c266af7))
- add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
- export snap methods from snapline ([#2904](https://github.com/antvis/x6/issues/2904)) ([826ccdd](https://github.com/antvis/x6/commit/826ccdd9a033486ad5b90d666340e46f6c266af7))
### Features
* attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))
- attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-snapline",
"version": "2.1.6",
"version": "2.1.7",
"description": "snapline plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -3,14 +3,14 @@ import { SnaplineImpl } from './snapline'
import { content } from './style/raw'
import './api'
export class Snapline extends Disposable {
export class Snapline extends Disposable implements Graph.Plugin {
public name = 'snapline'
private snaplineImpl: SnaplineImpl
public options: Snapline.Options
public name = 'snapline'
constructor(options: Snapline.Options = { enabled: true }) {
constructor(options: Snapline.Options = {}) {
super()
this.options = { tolerance: 10, ...options }
this.options = { enabled: true, tolerance: 10, ...options }
CssLoader.ensure(this.name, content)
}

View File

@ -1,15 +1,13 @@
## @antv/x6-plugin-stencil [2.0.3](https://github.com/antvis/x6/compare/@antv/x6-plugin-stencil@2.0.2...@antv/x6-plugin-stencil@2.0.3) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-stencil [2.0.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-stencil@2.0.1...@antv/x6-plugin-stencil@2.0.2) (2022-11-25)
## @antv/x6-plugin-stencil [2.0.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-stencil@2.0.0...@antv/x6-plugin-stencil@2.0.1) (2022-11-24)
### Bug Fixes
* add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
- add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-stencil",
"version": "2.0.2",
"version": "2.0.4",
"description": "stencil plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",
@ -38,10 +38,12 @@
"coveralls": "rss",
"pretest": "rss"
},
"peerDependencies": {
"@antv/x6": "^2.x",
"dependencies": {
"@antv/x6-plugin-dnd": "^2.x"
},
"peerDependencies": {
"@antv/x6": "^2.x"
},
"devDependencies": {
"@antv/x6": "^2.x",
"@antv/x6-plugin-dnd": "^2.0.x"

View File

@ -124,7 +124,10 @@ namespace GridLayout {
}
export function getMaxDim(nodes: Node[], name: 'width' | 'height') {
return nodes.reduce((memo, node) => Math.max(node.getSize()[name], memo), 0)
return nodes.reduce(
(memo, node) => Math.max(node?.getSize()[name], memo),
0,
)
}
export function getNodesInRow(
@ -134,7 +137,7 @@ namespace GridLayout {
) {
const res: Node[] = []
for (let i = columnCount * rowIndex, ii = i + columnCount; i < ii; i += 1) {
res.push(nodes[i])
if (nodes[i]) res.push(nodes[i])
}
return res
}
@ -146,7 +149,7 @@ namespace GridLayout {
) {
const res: Node[] = []
for (let i = columnIndex, ii = nodes.length; i < ii; i += columnCount) {
res.push(nodes[i])
if (nodes[i]) res.push(nodes[i])
}
return res
}

View File

@ -13,13 +13,13 @@ import { Dnd } from '@antv/x6-plugin-dnd'
import { grid } from './grid'
import { content } from './style/raw'
export class Stencil extends View {
export class Stencil extends View implements Graph.Plugin {
public name = 'stencil'
public readonly options: Stencil.Options
public readonly dnd: Dnd
protected readonly graphs: { [groupName: string]: Graph }
protected readonly groups: { [groupName: string]: HTMLElement }
protected readonly content: HTMLDivElement
public options: Stencil.Options
public dnd: Dnd
protected graphs: { [groupName: string]: Graph }
protected groups: { [groupName: string]: HTMLElement }
protected content: HTMLDivElement
protected get targetScroller() {
const target = this.options.target
@ -35,7 +35,7 @@ export class Stencil extends View {
return this.targetGraph.model
}
constructor(options: Partial<Stencil.Options>) {
constructor(options: Partial<Stencil.Options> = {}) {
super()
CssLoader.ensure(this.name, content)
@ -46,7 +46,10 @@ export class Stencil extends View {
...Stencil.defaultOptions,
...options,
} as Stencil.Options
this.init()
}
init() {
this.dnd = new Dnd(this.options)
this.onSearch = FunctionExt.debounce(this.onSearch, 200)
this.container = document.createElement('div')
@ -58,15 +61,15 @@ export class Stencil extends View {
)
this.options.collapsable =
options.collapsable &&
options.groups &&
options.groups.some((group) => group.collapsable !== false)
this.options.collapsable &&
this.options.groups &&
this.options.groups.some((group) => group.collapsable !== false)
if (this.options.collapsable) {
Dom.addClass(this.container, 'collapsable')
const collapsed =
options.groups &&
options.groups.every(
this.options.groups &&
this.options.groups.every(
(group) => group.collapsed || group.collapsable === false,
)
if (collapsed) {
@ -79,7 +82,7 @@ export class Stencil extends View {
title.innerHTML = this.options.title
Dom.appendTo(title, this.container)
if (options.search) {
if (this.options.search) {
Dom.addClass(this.container, 'searchable')
Dom.append(this.container, this.renderSearch())
}
@ -88,16 +91,16 @@ export class Stencil extends View {
Dom.addClass(this.content, this.prefixClassName(ClassNames.content))
Dom.appendTo(this.content, this.container)
const globalGraphOptions = options.stencilGraphOptions || {}
const globalGraphOptions = this.options.stencilGraphOptions || {}
if (options.groups && options.groups.length) {
options.groups.forEach((group) => {
if (this.options.groups && this.options.groups.length) {
this.options.groups.forEach((group) => {
const groupElem = document.createElement('div')
Dom.addClass(groupElem, this.prefixClassName(ClassNames.group))
Dom.attr(groupElem, 'data-name', group.name)
if (
(group.collapsable == null && options.collapsable) ||
(group.collapsable == null && this.options.collapsable) ||
group.collapsable !== false
) {
Dom.addClass(groupElem, 'collapsable')
@ -118,8 +121,8 @@ export class Stencil extends View {
...graphOptionsInGroup,
container: document.createElement('div'),
model: globalGraphOptions.model || new Model(),
width: group.graphWidth || options.stencilGraphWidth,
height: group.graphHeight || options.stencilGraphHeight,
width: group.graphWidth || this.options.stencilGraphWidth,
height: group.graphHeight || this.options.stencilGraphHeight,
interacting: false,
preventDefaultBlankAction: false,
})
@ -136,8 +139,8 @@ export class Stencil extends View {
...globalGraphOptions,
container: document.createElement('div'),
model: globalGraphOptions.model || new Model(),
width: options.stencilGraphWidth,
height: options.stencilGraphHeight,
width: this.options.stencilGraphWidth,
height: this.options.stencilGraphHeight,
interacting: false,
preventDefaultBlankAction: false,
})

View File

@ -1,41 +1,35 @@
## @antv/x6-plugin-transform [2.1.6](https://github.com/antvis/x6/compare/@antv/x6-plugin-transform@2.1.5...@antv/x6-plugin-transform@2.1.6) (2023-02-24)
### Bug Fixes
* transform active-handle class should remove when active removed ([#3298](https://github.com/antvis/x6/issues/3298)) ([709a141](https://github.com/antvis/x6/commit/709a141e28e9f25d54ece0ade353bd343ac0e55f))
- transform active-handle class should remove when active removed ([#3298](https://github.com/antvis/x6/issues/3298)) ([709a141](https://github.com/antvis/x6/commit/709a141e28e9f25d54ece0ade353bd343ac0e55f))
## @antv/x6-plugin-transform [2.1.5](https://github.com/antvis/x6/compare/@antv/x6-plugin-transform@2.1.4...@antv/x6-plugin-transform@2.1.5) (2022-12-24)
### Bug Fixes
* add defense for view in transform plugin ([#3092](https://github.com/antvis/x6/issues/3092)) ([fb8098c](https://github.com/antvis/x6/commit/fb8098c1c06440dd69f4e93881fd36f7e6de2a56))
- add defense for view in transform plugin ([#3092](https://github.com/antvis/x6/issues/3092)) ([fb8098c](https://github.com/antvis/x6/commit/fb8098c1c06440dd69f4e93881fd36f7e6de2a56))
## @antv/x6-plugin-transform [2.1.4](https://github.com/antvis/x6/compare/@antv/x6-plugin-transform@2.1.3...@antv/x6-plugin-transform@2.1.4) (2022-12-07)
### Bug Fixes
* make resizing options take effect ([#3014](https://github.com/antvis/x6/issues/3014)) ([604c024](https://github.com/antvis/x6/commit/604c0244cd71ec8e911754dfe524f12c04e4e9ad))
- make resizing options take effect ([#3014](https://github.com/antvis/x6/issues/3014)) ([604c024](https://github.com/antvis/x6/commit/604c0244cd71ec8e911754dfe524f12c04e4e9ad))
## @antv/x6-plugin-transform [2.1.2](https://github.com/antvis/x6/compare/@antv/x6-plugin-transform@2.1.1...@antv/x6-plugin-transform@2.1.2) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-plugin-transform [2.1.1](https://github.com/antvis/x6/compare/@antv/x6-plugin-transform@2.1.0...@antv/x6-plugin-transform@2.1.1) (2022-11-25)
# @antv/x6-plugin-transform [2.1.0](https://github.com/antvis/x6/compare/@antv/x6-plugin-transform@2.0.0...@antv/x6-plugin-transform@2.1.0) (2022-11-24)
### Bug Fixes
* add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
- add missing script for building style ([e683155](https://github.com/antvis/x6/commit/e68315528a202cbc5a9ad256d168943e001d7116))
### Features
* attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))
- attach plugin api and events to grpah instance ([#2864](https://github.com/antvis/x6/issues/2864)) ([774f547](https://github.com/antvis/x6/commit/774f547b85522eb2411dca949d36ecfe535503f3))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-plugin-transform",
"version": "2.1.6",
"version": "2.1.7",
"description": "transform plugin for X6",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -3,14 +3,19 @@ import { TransformImpl } from './transform'
import { content } from './style/raw'
import './api'
export class Transform extends Basecoat<Transform.EventArgs> {
export class Transform
extends Basecoat<Transform.EventArgs>
implements Graph.Plugin
{
public name = 'transform'
public options: Transform.Options
private graph: Graph
protected widgets: Map<Node, TransformImpl> = new Map()
public name = 'transform'
private disabled = false
constructor(public readonly options: Transform.Options = {}) {
constructor(options: Transform.Options = {}) {
super()
this.options = options
CssLoader.ensure(this.name, content)
}

View File

@ -1,52 +1,45 @@
## @antv/x6-react-components [2.0.7](https://github.com/antvis/x6/compare/@antv/x6-react-components@2.0.6...@antv/x6-react-components@2.0.7) (2023-01-31)
### Bug Fixes
* don't hide when click on color picker ([#3172](https://github.com/antvis/x6/issues/3172)) ([cae8625](https://github.com/antvis/x6/commit/cae8625feb20fd93cc8002fa6ed00d345d3cf33c))
- don't hide when click on color picker ([#3172](https://github.com/antvis/x6/issues/3172)) ([cae8625](https://github.com/antvis/x6/commit/cae8625feb20fd93cc8002fa6ed00d345d3cf33c))
## @antv/x6-react-components [2.0.6](https://github.com/antvis/x6/compare/@antv/x6-react-components@2.0.5...@antv/x6-react-components@2.0.6) (2023-01-17)
### Bug Fixes
* stop propagation when click menu item ([#3147](https://github.com/antvis/x6/issues/3147)) ([90dad14](https://github.com/antvis/x6/commit/90dad14d7e1ad8639b80b215596c8f4bad7b00ed))
- stop propagation when click menu item ([#3147](https://github.com/antvis/x6/issues/3147)) ([90dad14](https://github.com/antvis/x6/commit/90dad14d7e1ad8639b80b215596c8f4bad7b00ed))
## @antv/x6-react-components [2.0.5](https://github.com/antvis/x6/compare/@antv/x6-react-components@2.0.4...@antv/x6-react-components@2.0.5) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-react-components [2.0.4](https://github.com/antvis/x6/compare/@antv/x6-react-components@2.0.3...@antv/x6-react-components@2.0.4) (2022-11-25)
## @antv/x6-react-components [2.0.3](https://github.com/antvis/x6/compare/@antv/x6-react-components@2.0.2...@antv/x6-react-components@2.0.3) (2022-11-25)
### Bug Fixes
* support antd5 in react components ([#2933](https://github.com/antvis/x6/issues/2933)) ([2ecc213](https://github.com/antvis/x6/commit/2ecc213094250b476b533b444c0f3716f88b7987))
* update react type version ([#2937](https://github.com/antvis/x6/issues/2937)) ([d4df46a](https://github.com/antvis/x6/commit/d4df46ab40c0f2fb6e7a76fc0083d7b4710555b9))
- support antd5 in react components ([#2933](https://github.com/antvis/x6/issues/2933)) ([2ecc213](https://github.com/antvis/x6/commit/2ecc213094250b476b533b444c0f3716f88b7987))
- update react type version ([#2937](https://github.com/antvis/x6/issues/2937)) ([d4df46a](https://github.com/antvis/x6/commit/d4df46ab40c0f2fb6e7a76fc0083d7b4710555b9))
### Performance Improvements
* update deps ([f20127a](https://github.com/antvis/x6/commit/f20127af555d9b7beaac3a07ac308d5c0d4e53a3))
- update deps ([f20127a](https://github.com/antvis/x6/commit/f20127af555d9b7beaac3a07ac308d5c0d4e53a3))
## @antv/x6-react-components [2.0.3](https://github.com/antvis/x6/compare/@antv/x6-react-components@2.0.2...@antv/x6-react-components@2.0.3) (2022-11-24)
### Bug Fixes
* support antd5 in react components ([#2933](https://github.com/antvis/x6/issues/2933)) ([2ecc213](https://github.com/antvis/x6/commit/2ecc213094250b476b533b444c0f3716f88b7987))
* update react type version ([#2937](https://github.com/antvis/x6/issues/2937)) ([d4df46a](https://github.com/antvis/x6/commit/d4df46ab40c0f2fb6e7a76fc0083d7b4710555b9))
- support antd5 in react components ([#2933](https://github.com/antvis/x6/issues/2933)) ([2ecc213](https://github.com/antvis/x6/commit/2ecc213094250b476b533b444c0f3716f88b7987))
- update react type version ([#2937](https://github.com/antvis/x6/issues/2937)) ([d4df46a](https://github.com/antvis/x6/commit/d4df46ab40c0f2fb6e7a76fc0083d7b4710555b9))
## @antv/x6-react-components [2.0.2](https://github.com/antvis/x6/compare/@antv/x6-react-components@2.0.1...@antv/x6-react-components@2.0.2) (2022-11-24)
### Bug Fixes
* updae react-resize-detector version ([#2930](https://github.com/antvis/x6/issues/2930)) ([d6ae519](https://github.com/antvis/x6/commit/d6ae5199c00be6429a828f537b194adddd2b6aeb))
- updae react-resize-detector version ([#2930](https://github.com/antvis/x6/issues/2930)) ([d6ae519](https://github.com/antvis/x6/commit/d6ae5199c00be6429a828f537b194adddd2b6aeb))
## @antv/x6-react-components [2.0.1](https://github.com/antvis/x6/compare/@antv/x6-react-components@2.0.0...@antv/x6-react-components@2.0.1) (2022-11-24)

View File

@ -2,12 +2,9 @@
> React components for building x6 editors
[![MIT License](https://img.shields.io/github/license/antvis/x6?style=flat-square)](/LICENSE)
[![Language](https://img.shields.io/badge/language-typescript-blue.svg?style=flat-square)](https://www.typescriptlang.org)
[![MIT License](https://img.shields.io/github/license/antvis/x6?style=flat-square)](/LICENSE) [![Language](https://img.shields.io/badge/language-typescript-blue.svg?style=flat-square)](https://www.typescriptlang.org)
[![NPM Package](https://img.shields.io/npm/v/@antv/x6-react-components.svg?style=flat-square)](https://www.npmjs.com/package/@antv/x6-react-components)
[![NPM Downloads](http://img.shields.io/npm/dm/@antv/x6-react-components.svg?style=flat-square)](https://www.npmjs.com/package/@antv/x6-react-components)
[![NPM Dependencies](https://img.shields.io/david/antvis/x6?path=packages%2Fx6-react-components&style=flat-square)](https://www.npmjs.com/package/@antv/x6-react-components)
[![NPM Package](https://img.shields.io/npm/v/@antv/x6-react-components.svg?style=flat-square)](https://www.npmjs.com/package/@antv/x6-react-components) [![NPM Downloads](http://img.shields.io/npm/dm/@antv/x6-react-components.svg?style=flat-square)](https://www.npmjs.com/package/@antv/x6-react-components) [![NPM Dependencies](https://img.shields.io/david/antvis/x6?path=packages%2Fx6-react-components&style=flat-square)](https://www.npmjs.com/package/@antv/x6-react-components)
## Components

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-react-components",
"version": "2.0.7",
"version": "2.0.8",
"description": "React components for building x6 editors",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -1,22 +1,19 @@
## @antv/x6-react-shape [2.0.4](https://github.com/antvis/x6/compare/@antv/x6-react-shape@2.0.3...@antv/x6-react-shape@2.0.4) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-react-shape [2.0.3](https://github.com/antvis/x6/compare/@antv/x6-react-shape@2.0.2...@antv/x6-react-shape@2.0.3) (2022-11-25)
## @antv/x6-react-shape [2.0.2](https://github.com/antvis/x6/compare/@antv/x6-react-shape@2.0.1...@antv/x6-react-shape@2.0.2) (2022-11-25)
### Performance Improvements
* update deps ([f20127a](https://github.com/antvis/x6/commit/f20127af555d9b7beaac3a07ac308d5c0d4e53a3))
- update deps ([f20127a](https://github.com/antvis/x6/commit/f20127af555d9b7beaac3a07ac308d5c0d4e53a3))
## @antv/x6-react-shape [2.0.1](https://github.com/antvis/x6/compare/@antv/x6-react-shape@2.0.0...@antv/x6-react-shape@2.0.1) (2022-11-24)
### Bug Fixes
* optimize typo for react-shape ([#2870](https://github.com/antvis/x6/issues/2870)) ([86412e2](https://github.com/antvis/x6/commit/86412e23d242347d6ee1c9ccd63a6ccf3caf4c49))
- optimize typo for react-shape ([#2870](https://github.com/antvis/x6/issues/2870)) ([86412e2](https://github.com/antvis/x6/commit/86412e23d242347d6ee1c9ccd63a6ccf3caf4c49))

View File

@ -4,4 +4,4 @@
## Installation
## Usage
## Usage

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-react-shape",
"version": "2.1.1",
"version": "2.2.2",
"description": "X6 shape for rendering react components.",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -9,6 +9,10 @@ import { Wrap } from './wrap'
export class ReactShapeView extends NodeView<ReactShape> {
root?: Root
protected targetId() {
return `${this.graph.view.cid}:${this.cell.id}`
}
getComponentContainer() {
return this.selectors && (this.selectors.foContent as HTMLDivElement)
}
@ -29,7 +33,7 @@ export class ReactShapeView extends NodeView<ReactShape> {
const elem = React.createElement(Wrap, { node, graph: this.graph })
if (Portal.isActive()) {
const portal = createPortal(elem, container) as ReactPortal
Portal.connect(this.cell.id, portal)
Portal.connect(this.targetId(), portal)
} else {
this.root = createRoot(container)
this.root.render(elem)
@ -71,7 +75,7 @@ export class ReactShapeView extends NodeView<ReactShape> {
unmount() {
if (Portal.isActive()) {
Portal.disconnect(this.cell.id)
Portal.disconnect(this.targetId())
}
this.unmountReactComponent()
super.unmount()

View File

@ -1,31 +1,27 @@
## @antv/x6-vue-shape [2.0.9](https://github.com/antvis/x6/compare/@antv/x6-vue-shape@2.0.8...@antv/x6-vue-shape@2.0.9) (2022-12-21)
### Bug Fixes
* get graph from right place ([#3078](https://github.com/antvis/x6/issues/3078)) ([844ee5f](https://github.com/antvis/x6/commit/844ee5fa043cbcd788ec1693f88576e797426228))
- get graph from right place ([#3078](https://github.com/antvis/x6/issues/3078)) ([844ee5f](https://github.com/antvis/x6/commit/844ee5fa043cbcd788ec1693f88576e797426228))
## @antv/x6-vue-shape [2.0.7](https://github.com/antvis/x6/compare/@antv/x6-vue-shape@2.0.6...@antv/x6-vue-shape@2.0.7) (2022-12-09)
### Bug Fixes
* cannot read properties of undefined when unmount vue component ([#3024](https://github.com/antvis/x6/issues/3024)) ([187e318](https://github.com/antvis/x6/commit/187e318aee8622591781d3b8fc45d72a4d54a989))
- cannot read properties of undefined when unmount vue component ([#3024](https://github.com/antvis/x6/issues/3024)) ([187e318](https://github.com/antvis/x6/commit/187e318aee8622591781d3b8fc45d72a4d54a989))
## @antv/x6-vue-shape [2.0.4](https://github.com/antvis/x6/compare/@antv/x6-vue-shape@2.0.3...@antv/x6-vue-shape@2.0.4) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6-vue-shape [2.0.3](https://github.com/antvis/x6/compare/@antv/x6-vue-shape@2.0.2...@antv/x6-vue-shape@2.0.3) (2022-11-25)
## @antv/x6-vue-shape [2.0.2](https://github.com/antvis/x6/compare/@antv/x6-vue-shape@2.0.1...@antv/x6-vue-shape@2.0.2) (2022-11-24)
### Bug Fixes
* updae react-resize-detector version ([#2930](https://github.com/antvis/x6/issues/2930)) ([d6ae519](https://github.com/antvis/x6/commit/d6ae5199c00be6429a828f537b194adddd2b6aeb))
- updae react-resize-detector version ([#2930](https://github.com/antvis/x6/issues/2930)) ([d6ae519](https://github.com/antvis/x6/commit/d6ae5199c00be6429a828f537b194adddd2b6aeb))
## @antv/x6-vue-shape [2.0.1](https://github.com/antvis/x6/compare/@antv/x6-vue-shape@2.0.0...@antv/x6-vue-shape@2.0.1) (2022-11-24)

View File

@ -35,8 +35,7 @@ graph.addNode({
},
components: {
HelloWorld,
}
},
},
})
```

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6-vue-shape",
"version": "2.0.10",
"version": "2.0.11",
"description": "X6 shape for rendering vue components.",
"main": "lib/index.js",
"module": "es/index.js",

View File

@ -1,116 +1,100 @@
## @antv/x6 [2.5.2](https://github.com/antvis/x6/compare/@antv/x6@2.5.1...@antv/x6@2.5.2) (2023-03-02)
### Bug Fixes
* add excludeShapes options for manhattan router ([#3334](https://github.com/antvis/x6/issues/3334)) ([c76a23b](https://github.com/antvis/x6/commit/c76a23b53425f5cbb7f767c0fe5510f3f81c417c))
- add excludeShapes options for manhattan router ([#3334](https://github.com/antvis/x6/issues/3334)) ([c76a23b](https://github.com/antvis/x6/commit/c76a23b53425f5cbb7f767c0fe5510f3f81c417c))
# @antv/x6 [2.3.0](https://github.com/antvis/x6/compare/@antv/x6@2.2.1...@antv/x6@2.3.0) (2023-02-06)
### Bug Fixes
* **scheduler:** remove spammy console.log ([#3200](https://github.com/antvis/x6/issues/3200)) ([1f83a2b](https://github.com/antvis/x6/commit/1f83a2b8a84b53303293e724e7f9d0ee49182efc))
- **scheduler:** remove spammy console.log ([#3200](https://github.com/antvis/x6/issues/3200)) ([1f83a2b](https://github.com/antvis/x6/commit/1f83a2b8a84b53303293e724e7f9d0ee49182efc))
### Features
* add options for positionCell api ([#3208](https://github.com/antvis/x6/issues/3208)) ([58c0fe4](https://github.com/antvis/x6/commit/58c0fe459c0314997440b4af7dc0443abe199924))
- add options for positionCell api ([#3208](https://github.com/antvis/x6/issues/3208)) ([58c0fe4](https://github.com/antvis/x6/commit/58c0fe459c0314997440b4af7dc0443abe199924))
## @antv/x6 [2.2.1](https://github.com/antvis/x6/compare/@antv/x6@2.2.0...@antv/x6@2.2.1) (2023-02-02)
### Bug Fixes
* ensure the container in html view ([#3196](https://github.com/antvis/x6/issues/3196)) ([3a59703](https://github.com/antvis/x6/commit/3a59703f1c2da3ac8c8471eb9b864ac4cf468f97))
- ensure the container in html view ([#3196](https://github.com/antvis/x6/issues/3196)) ([3a59703](https://github.com/antvis/x6/commit/3a59703f1c2da3ac8c8471eb9b864ac4cf468f97))
# @antv/x6 [2.2.0](https://github.com/antvis/x6/compare/@antv/x6@2.1.7...@antv/x6@2.2.0) (2023-01-31)
### Features
* add port events ([#3185](https://github.com/antvis/x6/issues/3185)) ([3265fe5](https://github.com/antvis/x6/commit/3265fe5b983f22e34d60c647212824961ecfdab5))
- add port events ([#3185](https://github.com/antvis/x6/issues/3185)) ([3265fe5](https://github.com/antvis/x6/commit/3265fe5b983f22e34d60c647212824961ecfdab5))
## @antv/x6 [2.1.6](https://github.com/antvis/x6/compare/@antv/x6@2.1.5...@antv/x6@2.1.6) (2023-01-19)
## @antv/x6 [2.1.5](https://github.com/antvis/x6/compare/@antv/x6@2.1.4...@antv/x6@2.1.5) (2023-01-13)
### Bug Fixes
* update group even group is empty ([#3117](https://github.com/antvis/x6/issues/3117)) ([6abd068](https://github.com/antvis/x6/commit/6abd0683eab22eb0fa1a4702642ab76b91320694))
- update group even group is empty ([#3117](https://github.com/antvis/x6/issues/3117)) ([6abd068](https://github.com/antvis/x6/commit/6abd0683eab22eb0fa1a4702642ab76b91320694))
## @antv/x6 [2.1.4](https://github.com/antvis/x6/compare/@antv/x6@2.1.3...@antv/x6@2.1.4) (2023-01-03)
### Bug Fixes
* optimize rendering logic to prevent loops ([#3108](https://github.com/antvis/x6/issues/3108)) ([45337e4](https://github.com/antvis/x6/commit/45337e4a62224aaffd60fc8b2670a071c5560796))
- optimize rendering logic to prevent loops ([#3108](https://github.com/antvis/x6/issues/3108)) ([45337e4](https://github.com/antvis/x6/commit/45337e4a62224aaffd60fc8b2670a071c5560796))
## @antv/x6 [2.1.3](https://github.com/antvis/x6/compare/@antv/x6@2.1.2...@antv/x6@2.1.3) (2022-12-24)
### Bug Fixes
* schedule edge when source and target is not ready ([#3090](https://github.com/antvis/x6/issues/3090)) ([019333d](https://github.com/antvis/x6/commit/019333d79d7f22c44c400f29d501497f4323af1a))
- schedule edge when source and target is not ready ([#3090](https://github.com/antvis/x6/issues/3090)) ([019333d](https://github.com/antvis/x6/commit/019333d79d7f22c44c400f29d501497f4323af1a))
## @antv/x6 [2.1.1](https://github.com/antvis/x6/compare/@antv/x6@2.1.0...@antv/x6@2.1.1) (2022-12-19)
### Bug Fixes
* arrowhead not get options bug ([#3065](https://github.com/antvis/x6/issues/3065)) ([3b668fe](https://github.com/antvis/x6/commit/3b668feb4eac47994f52d0cc977d22a8a2c06acd))
* set snapToGrid to false by default ([#3066](https://github.com/antvis/x6/issues/3066)) ([e2bb71d](https://github.com/antvis/x6/commit/e2bb71d95484b29187fafca97f1a386e9b984095))
- arrowhead not get options bug ([#3065](https://github.com/antvis/x6/issues/3065)) ([3b668fe](https://github.com/antvis/x6/commit/3b668feb4eac47994f52d0cc977d22a8a2c06acd))
- set snapToGrid to false by default ([#3066](https://github.com/antvis/x6/issues/3066)) ([e2bb71d](https://github.com/antvis/x6/commit/e2bb71d95484b29187fafca97f1a386e9b984095))
# @antv/x6 [2.1.0](https://github.com/antvis/x6/compare/@antv/x6@2.0.9...@antv/x6@2.1.0) (2022-12-19)
### Features
* add snapToGrid options for manhattan router ([#3062](https://github.com/antvis/x6/issues/3062)) ([824560d](https://github.com/antvis/x6/commit/824560ddda7016158cce3166773e1af009bfe498))
- add snapToGrid options for manhattan router ([#3062](https://github.com/antvis/x6/issues/3062)) ([824560d](https://github.com/antvis/x6/commit/824560ddda7016158cce3166773e1af009bfe498))
## @antv/x6 [2.0.9](https://github.com/antvis/x6/compare/@antv/x6@2.0.8...@antv/x6@2.0.9) (2022-12-16)
### Bug Fixes
* :bug: char ghosting when edit text ([#2560](https://github.com/antvis/x6/issues/2560)) ([#3043](https://github.com/antvis/x6/issues/3043)) ([15284e7](https://github.com/antvis/x6/commit/15284e778a09f4f2e5a8f777330744b0cfe88e9e))
- :bug: char ghosting when edit text ([#2560](https://github.com/antvis/x6/issues/2560)) ([#3043](https://github.com/antvis/x6/issues/3043)) ([15284e7](https://github.com/antvis/x6/commit/15284e778a09f4f2e5a8f777330744b0cfe88e9e))
## @antv/x6 [2.0.8](https://github.com/antvis/x6/compare/@antv/x6@2.0.7...@antv/x6@2.0.8) (2022-12-08)
### Bug Fixes
* trigger preventDefault by origin event ([#3017](https://github.com/antvis/x6/issues/3017)) ([4a6a634](https://github.com/antvis/x6/commit/4a6a634a8acfad5c1a7bb93ac17fb3b97239e853))
- trigger preventDefault by origin event ([#3017](https://github.com/antvis/x6/issues/3017)) ([4a6a634](https://github.com/antvis/x6/commit/4a6a634a8acfad5c1a7bb93ac17fb3b97239e853))
## @antv/x6 [2.0.7](https://github.com/antvis/x6/compare/@antv/x6@2.0.6...@antv/x6@2.0.7) (2022-12-06)
### Bug Fixes
* hide elems when visible is false ([#3007](https://github.com/antvis/x6/issues/3007)) ([057d520](https://github.com/antvis/x6/commit/057d5209ff827d0231ecc6562e768907f75aff2d))
- hide elems when visible is false ([#3007](https://github.com/antvis/x6/issues/3007)) ([057d520](https://github.com/antvis/x6/commit/057d5209ff827d0231ecc6562e768907f75aff2d))
## @antv/x6 [2.0.4](https://github.com/antvis/x6/compare/@antv/x6@2.0.3...@antv/x6@2.0.4) (2022-11-25)
### Bug Fixes
* npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
- npm version ([cb0cfde](https://github.com/antvis/x6/commit/cb0cfdeb4dbe8858569e6899db08ccb9ab8ba4e7))
## @antv/x6 [2.0.3](https://github.com/antvis/x6/compare/@antv/x6@2.0.2...@antv/x6@2.0.3) (2022-11-25)
## @antv/x6 [2.0.2](https://github.com/antvis/x6/compare/@antv/x6@2.0.1...@antv/x6@2.0.2) (2022-11-24)
### Bug Fixes
* get correct center when zoom ([#2934](https://github.com/antvis/x6/issues/2934)) ([557d2df](https://github.com/antvis/x6/commit/557d2df1529226e505e3488a43fa358191d79271))
- get correct center when zoom ([#2934](https://github.com/antvis/x6/issues/2934)) ([557d2df](https://github.com/antvis/x6/commit/557d2df1529226e505e3488a43fa358191d79271))
## @antv/x6 [2.0.1](https://github.com/antvis/x6/compare/@antv/x6@2.0.0...@antv/x6@2.0.1) (2022-11-24)
### Bug Fixes
* Cannot use "this" here: [#2824](https://github.com/antvis/x6/issues/2824) ([#2855](https://github.com/antvis/x6/issues/2855)) ([10347d0](https://github.com/antvis/x6/commit/10347d069b23e4cfaf156138a39e2f5f996f0e29))
* resize graph when scale scroller ([#2903](https://github.com/antvis/x6/issues/2903)) ([cee4aa4](https://github.com/antvis/x6/commit/cee4aa4e53b2821ed11d5602fccdb36625957c72))
* sync render when change position ([#2860](https://github.com/antvis/x6/issues/2860)) ([2194769](https://github.com/antvis/x6/commit/2194769e362ce60d19652b29047a394cac4077d0))
- Cannot use "this" here: [#2824](https://github.com/antvis/x6/issues/2824) ([#2855](https://github.com/antvis/x6/issues/2855)) ([10347d0](https://github.com/antvis/x6/commit/10347d069b23e4cfaf156138a39e2f5f996f0e29))
- resize graph when scale scroller ([#2903](https://github.com/antvis/x6/issues/2903)) ([cee4aa4](https://github.com/antvis/x6/commit/cee4aa4e53b2821ed11d5602fccdb36625957c72))
- sync render when change position ([#2860](https://github.com/antvis/x6/issues/2860)) ([2194769](https://github.com/antvis/x6/commit/2194769e362ce60d19652b29047a394cac4077d0))

View File

@ -1,6 +1,6 @@
{
"name": "@antv/x6",
"version": "2.5.6",
"version": "2.12.1",
"description": "JavaScript diagramming library that uses SVG and HTML for rendering",
"main": "lib/index.js",
"module": "es/index.js",
@ -44,8 +44,8 @@
"pretest": "rss"
},
"dependencies": {
"@antv/x6-common": "^2.0.11",
"@antv/x6-geometry": "^2.0.4",
"@antv/x6-common": "^2.0.13",
"@antv/x6-geometry": "^2.0.5",
"utility-types": "^3.10.0"
},
"author": {

View File

@ -21,10 +21,10 @@ import { SizeManager as Size } from './size'
export class Graph extends Basecoat<EventArgs> {
private installedPlugins: Set<Graph.Plugin> = new Set()
public model: Model
public readonly options: GraphOptions.Definition
public readonly css: Css
public readonly model: Model
public readonly view: GraphView
public readonly grid: Grid
public readonly defs: Defs
@ -1225,18 +1225,6 @@ export class Graph extends Basecoat<EventArgs> {
) as T
}
disablePlugins(plugins: string[] | string) {
let postPlugins = plugins
if (!Array.isArray(postPlugins)) {
postPlugins = [postPlugins]
}
const aboutToChangePlugins = this.getPlugins(postPlugins)
aboutToChangePlugins?.forEach((plugin) => {
plugin?.disable?.()
})
return this
}
enablePlugins(plugins: string[] | string) {
let postPlugins = plugins
if (!Array.isArray(postPlugins)) {
@ -1249,6 +1237,23 @@ export class Graph extends Basecoat<EventArgs> {
return this
}
disablePlugins(plugins: string[] | string) {
let postPlugins = plugins
if (!Array.isArray(postPlugins)) {
postPlugins = [postPlugins]
}
const aboutToChangePlugins = this.getPlugins(postPlugins)
aboutToChangePlugins?.forEach((plugin) => {
plugin?.disable?.()
})
return this
}
isPluginEnabled(pluginName: string) {
const pluginIns = this.getPlugin(pluginName)
return pluginIns?.isEnabled?.()
}
disposePlugins(plugins: string[] | string) {
let postPlugins = plugins
if (!Array.isArray(postPlugins)) {
@ -1261,11 +1266,6 @@ export class Graph extends Basecoat<EventArgs> {
return this
}
isPluginEnabled(pluginName: string) {
const pluginIns = this.getPlugin(pluginName)
return pluginIns?.isEnabled?.()
}
// #endregion
// #region dispose
@ -1411,8 +1411,9 @@ export namespace Graph {
name: string
init: (graph: Graph, ...options: any[]) => any
dispose: () => void
disable?: () => void
enable?: () => void
disable?: () => void
isEnabled?: () => boolean
}
}

View File

@ -81,6 +81,9 @@ export class MouseWheel extends Base {
// webkit and to avoid rounding errors for zoom steps
this.cumulatedFactor =
Math.round(this.currentScale * factor * 20) / 20 / this.currentScale
if (this.cumulatedFactor === 1) {
this.cumulatedFactor = 1.05
}
}
} else {
// zoomout
@ -95,6 +98,9 @@ export class MouseWheel extends Base {
Math.round(this.currentScale * (1 / factor) * 20) /
20 /
this.currentScale
if (this.cumulatedFactor === 1) {
this.cumulatedFactor = 0.95
}
}
}

View File

@ -37,7 +37,7 @@ export namespace Options {
max?: number
}
moveThreshold: 0
moveThreshold: number
clickThreshold: number
magnetThreshold: number | 'onleave'
preventDefaultDblClick: boolean
@ -56,7 +56,10 @@ export namespace Options {
onPortRendered?: (args: OnPortRenderedArgs) => void
onEdgeLabelRendered?: (args: OnEdgeLabelRenderedArgs) => void
createCellView?: (this: Graph, cell: Cell) => CellView | null | undefined
createCellView?: (
this: Graph,
cell: Cell,
) => typeof CellView | (new (...args: any[]) => CellView) | null | undefined
}
export interface ManualBooleans {
@ -111,7 +114,7 @@ export namespace Options {
/**
* Specify whether connect to point on the graph is allowed.
*/
allowBlank?:
allowBlank:
| boolean
| ((this: Graph, args: ValidateConnectionArgs) => boolean)
@ -148,7 +151,7 @@ export namespace Options {
* Specify whether more than one edge connected to the same source and
* target node is allowed.
*/
allowMulti?:
allowMulti:
| boolean
| 'withPort'
| ((this: Graph, args: ValidateConnectionArgs) => boolean)
@ -175,6 +178,15 @@ export namespace Options {
router: string | Router.NativeItem | Router.ManaualItem
connector: string | Connector.NativeItem | Connector.ManaualItem
createEdge?: (
this: Graph,
args: {
sourceCell: Cell
sourceView: CellView
sourceMagnet: Element
},
) => Nilable<Edge> | void
/**
* Check whether to add a new edge to the graph when user clicks
* on an a magnet.
@ -189,15 +201,6 @@ export namespace Options {
},
) => boolean
createEdge?: (
this: Graph,
args: {
sourceCell: Cell
sourceView: CellView
sourceMagnet: Element
},
) => Nilable<Edge> | void
/**
* Custom validation on stop draggin the edge arrowhead(source/target).
* If the function returns `false`, the edge is either removed(edges
@ -440,6 +443,8 @@ export namespace Options {
allowNode: true,
allowEdge: false,
allowPort: true,
allowBlank: true,
allowMulti: true,
highlight: false,
anchor: 'center',

View File

@ -797,7 +797,8 @@ export class Edge<
prevParent.unembed(this, options)
}
if (newParent) {
// Embeds the edge if source and target are not same
if (newParent && (!prevParent || prevParent.id !== newParent.id)) {
newParent.embed(this, options)
}
@ -923,14 +924,24 @@ export namespace Edge {
| ConnectionPoint.ManaualItem
}
export type NodeAnchorItem =
| string
| NodeAnchor.NativeItem
| NodeAnchor.ManaualItem
export type EdgeAnchorItem =
| string
| EdgeAnchor.NativeItem
| EdgeAnchor.ManaualItem
export interface SetCellTerminalArgs extends SetTerminalCommonArgs {
port?: string
priority?: boolean
anchor?: string | NodeAnchor.NativeItem | NodeAnchor.ManaualItem
anchor?: NodeAnchorItem
}
export interface SetEdgeTerminalArgs extends SetTerminalCommonArgs {
anchor?: string | EdgeAnchor.NativeItem | EdgeAnchor.ManaualItem
anchor?: EdgeAnchorItem
}
export interface TerminalPointData

View File

@ -1,5 +1,5 @@
import { Point } from '@antv/x6-geometry'
import { Dom, FunctionExt } from '@antv/x6-common'
import { Dom, FunctionExt, NumberExt, ObjectExt } from '@antv/x6-common'
import { ToolsView } from '../../view/tool'
import { Cell, Edge } from '../../model'
import { CellView, NodeView, EdgeView } from '../../view'
@ -9,23 +9,24 @@ export class CellEditor extends ToolsView.ToolItem<
NodeView | EdgeView,
CellEditor.CellEditorOptions & { event: Dom.EventObject }
> {
private editor: HTMLDivElement
private editor: HTMLDivElement | null
private labelIndex = -1
private distance = 0.5
private event: Dom.DoubleClickEvent
private dblClick = this.onCellDblClick.bind(this)
render() {
this.createElement()
this.updateEditor()
this.autoFocus()
this.delegateDocumentEvents(this.options.documentEvents!)
return this
onRender() {
const cellView = this.cellView as CellView
if (cellView) {
cellView.on('cell:dblclick', this.dblClick)
}
}
createElement() {
const { cell } = this
const classNames = [
this.prefixClassName(`${cell.isEdge() ? 'edge' : 'node'}-tool-editor`),
this.prefixClassName(
`${this.cell.isEdge() ? 'edge' : 'node'}-tool-editor`,
),
this.prefixClassName('cell-tool-editor'),
]
this.editor = ToolsView.createElement('div', false) as HTMLDivElement
@ -34,88 +35,141 @@ export class CellEditor extends ToolsView.ToolItem<
this.container.appendChild(this.editor)
}
updateEditor() {
const { graph, cell, editor } = this
const style = editor.style
// set tool position
let pos = new Point()
let minWidth = 20
if (cell.isNode()) {
pos = cell.getBBox().center
minWidth = cell.size().width - 4
} else if (cell.isEdge()) {
const e = this.options.event
const target = e.target
const parent = target.parentElement
const isEdgeLabel =
parent && Dom.hasClass(parent, this.prefixClassName('edge-label'))
if (isEdgeLabel) {
const index = parent.getAttribute('data-index') || '0'
this.labelIndex = parseInt(index, 10)
const matrix = parent.getAttribute('transform')
const { translation } = Dom.parseTransformString(matrix)
pos = new Point(translation.tx, translation.ty)
minWidth = Util.getBBox(target).width
} else {
if (!this.options.labelAddable) {
return this
}
pos = graph.clientToLocal(Point.create(e.clientX, e.clientY))
const view = this.cellView as EdgeView
const d = view.path.closestPointLength(pos)
this.distance = d
}
removeElement() {
this.undelegateDocumentEvents()
if (this.editor) {
this.container.removeChild(this.editor)
this.editor = null
}
pos = graph.localToGraph(pos)
style.left = `${pos.x}px`
style.top = `${pos.y}px`
style.minWidth = `${minWidth}px`
}
// set tool transform
const scale = graph.scale()
style.transform = `scale(${scale.sx}, ${scale.sy}) translate(-50%, -50%)`
updateEditor() {
const { cell, editor } = this
if (!editor) {
return
}
const { style } = editor
if (cell.isNode()) {
this.updateNodeEditorTransform()
} else if (cell.isEdge()) {
this.updateEdgeEditorTransform()
}
// set font style
const attrs = this.options.attrs
const { attrs } = this.options
style.fontSize = `${attrs.fontSize}px`
style.fontFamily = attrs.fontFamily
style.color = attrs.color
style.backgroundColor = attrs.backgroundColor
// set init value
const getText = this.options.getText
let text
if (typeof getText === 'function') {
text = FunctionExt.call(getText, this.cellView, {
cell: this.cell,
index: this.labelIndex,
})
}
editor.innerText = text || ''
// clear display value when edit status because char ghosting.
this.setCellText('')
const text = this.getCellText() || ''
editor.innerText = text
this.setCellText('') // clear display value when edit status because char ghosting.
return this
}
updateNodeEditorTransform() {
const { graph, cell, editor } = this
if (!editor) {
return
}
let pos = Point.create()
let minWidth = 20
let translate = ''
let { x, y } = this.options
if (typeof x !== 'undefined' && typeof y !== 'undefined') {
const bbox = cell.getBBox()
x = NumberExt.normalizePercentage(x, bbox.width)
y = NumberExt.normalizePercentage(y, bbox.height)
pos = bbox.topLeft.translate(x, y)
minWidth = bbox.width - x * 2
} else {
const bbox = cell.getBBox()
pos = bbox.center
minWidth = bbox.width - 4
translate = 'translate(-50%, -50%)'
}
const scale = graph.scale()
const { style } = editor
pos = graph.localToGraph(pos)
style.left = `${pos.x}px`
style.top = `${pos.y}px`
style.transform = `scale(${scale.sx}, ${scale.sy}) ${translate}`
style.minWidth = `${minWidth}px`
}
updateEdgeEditorTransform() {
if (!this.event) {
return
}
const { graph, editor } = this
if (!editor) {
return
}
let pos = Point.create()
let minWidth = 20
const { style } = editor
const target = this.event.target
const parent = target.parentElement
const isEdgeLabel =
parent && Dom.hasClass(parent, this.prefixClassName('edge-label'))
if (isEdgeLabel) {
const index = parent.getAttribute('data-index') || '0'
this.labelIndex = parseInt(index, 10)
const matrix = parent.getAttribute('transform')
const { translation } = Dom.parseTransformString(matrix)
pos = new Point(translation.tx, translation.ty)
minWidth = Util.getBBox(target).width
} else {
if (!this.options.labelAddable) {
return this
}
pos = graph.clientToLocal(
Point.create(this.event.clientX, this.event.clientY),
)
const view = this.cellView as EdgeView
const d = view.path.closestPointLength(pos)
this.distance = d
this.labelIndex = -1
}
pos = graph.localToGraph(pos)
const scale = graph.scale()
style.left = `${pos.x}px`
style.top = `${pos.y}px`
style.minWidth = `${minWidth}px`
style.transform = `scale(${scale.sx}, ${scale.sy}) translate(-50%, -50%)`
}
onDocumentMouseDown(e: Dom.MouseDownEvent) {
if (e.target !== this.editor) {
const cell = this.cell
if (this.editor && e.target !== this.editor) {
const value = this.editor.innerText.replace(/\n$/, '') || ''
// set value
// when value is null, we will remove label in edge
// set value, when value is null, we will remove label in edge
this.setCellText(value !== '' ? value : null)
// remove tool
cell.removeTool(cell.isEdge() ? 'edge-editor' : 'node-editor')
this.undelegateDocumentEvents()
this.removeElement()
}
}
onDblClick(e: Dom.DoubleClickEvent) {
onCellDblClick({ e }: { e: Dom.DoubleClickEvent }) {
e.stopPropagation()
this.removeElement()
this.event = e
this.createElement()
this.updateEditor()
this.autoFocus()
this.delegateDocumentEvents(this.options.documentEvents!)
}
onMouseDown(e: Dom.MouseDownEvent) {
@ -124,13 +178,15 @@ export class CellEditor extends ToolsView.ToolItem<
autoFocus() {
setTimeout(() => {
this.editor.focus()
this.selectText()
if (this.editor) {
this.editor.focus()
this.selectText()
}
})
}
selectText() {
if (window.getSelection) {
if (window.getSelection && this.editor) {
const range = document.createRange()
const selection = window.getSelection()!
range.selectNodeContents(this.editor)
@ -139,6 +195,26 @@ export class CellEditor extends ToolsView.ToolItem<
}
}
getCellText() {
const { getText } = this.options
if (typeof getText === 'function') {
return FunctionExt.call(getText, this.cellView, {
cell: this.cell,
index: this.labelIndex,
})
}
if (typeof getText === 'string') {
if (this.cell.isNode()) {
return this.cell.attr(getText)
}
if (this.cell.isEdge()) {
if (this.labelIndex !== -1) {
return this.cell.prop(`labels/${this.labelIndex}/attrs/${getText}`)
}
}
}
}
setCellText(value: string | null) {
const setText = this.options.setText
if (typeof setText === 'function') {
@ -148,12 +224,52 @@ export class CellEditor extends ToolsView.ToolItem<
index: this.labelIndex,
distance: this.distance,
})
return
}
if (typeof setText === 'string') {
if (this.cell.isNode()) {
if (value !== null) {
this.cell.attr(setText, value)
}
return
}
if (this.cell.isEdge()) {
const edge = this.cell as Edge
if (this.labelIndex === -1) {
if (value) {
const newLabel = {
position: {
distance: this.distance,
},
attrs: {},
}
ObjectExt.setByPath(newLabel, `attrs/${setText}`, value)
edge.appendLabel(newLabel)
}
} else {
if (value !== null) {
edge.prop(`labels/${this.labelIndex}/attrs/${setText}`, value)
} else if (typeof this.labelIndex === 'number') {
edge.removeLabelAt(this.labelIndex)
}
}
}
}
}
protected onRemove() {
const cellView = this.cellView as CellView
if (cellView) {
cellView.off('cell:dblclick', this.dblClick)
}
this.removeElement()
}
}
export namespace CellEditor {
export interface CellEditorOptions extends ToolsView.ToolItem.Options {
x?: number | string
y?: number | string
attrs: {
fontSize: number
fontFamily: string
@ -161,22 +277,26 @@ export namespace CellEditor {
backgroundColor: string
}
labelAddable?: boolean
getText: (
this: CellView,
args: {
cell: Cell
index?: number
},
) => string
setText: (
this: CellView,
args: {
cell: Cell
value: string | null
index?: number
distance?: number
},
) => void
getText:
| ((
this: CellView,
args: {
cell: Cell
index?: number
},
) => string)
| string
setText:
| ((
this: CellView,
args: {
cell: Cell
value: string | null
index?: number
distance?: number
},
) => void)
| string
}
}
@ -185,7 +305,6 @@ export namespace CellEditor {
tagName: 'div',
isSVGElement: false,
events: {
dblclick: 'onDblClick',
mousedown: 'onMouseDown',
},
documentEvents: {
@ -202,14 +321,8 @@ export namespace CellEditor {
color: '#000',
backgroundColor: '#fff',
},
getText({ cell }) {
return cell.attr('text/text')
},
setText({ cell, value }) {
if (value !== null) {
cell.attr('text/text', value)
}
},
getText: 'text/text',
setText: 'text/text',
})
export const EdgeEditor = CellEditor.define<CellEditorOptions>({
@ -220,34 +333,7 @@ export namespace CellEditor {
backgroundColor: '#fff',
},
labelAddable: true,
getText({ cell, index }) {
if (index === -1) {
return ''
}
return cell.prop(`labels/${index}/attrs/label/text`)
},
setText({ cell, value, index, distance }) {
const edge = cell as Edge
if (index === -1) {
if (value) {
edge.appendLabel({
position: {
distance: distance!,
},
attrs: {
label: {
text: value,
},
},
})
}
} else {
if (value !== null) {
edge.prop(`labels/${index}/attrs/label/text`, value)
} else if (typeof index === 'number') {
edge.removeLabelAt(index)
}
}
},
getText: 'label/text',
setText: 'label/text',
})
}

View File

@ -3,7 +3,7 @@ import { Point, Rectangle } from '@antv/x6-geometry'
import { Base } from '../graph/base'
import { Cell } from '../model'
import { Scheduler } from './scheduler'
import { CellView } from '../view'
import { CellView, EdgeView } from '../view'
import { Util } from '../util'
export class Renderer extends Base {
@ -78,37 +78,35 @@ export class Renderer extends Base {
}) as CellView[]
}
findViewsInArea(
rect: Rectangle.RectangleLike,
options: { strict?: boolean } = {},
) {
const area = Rectangle.create(rect)
return this.model
.getNodes()
.map((node) => this.findViewByCell(node))
.filter((view) => {
if (view) {
const bbox = Util.getBBox(view.container as SVGElement, {
target: this.graph.view.stage,
})
return options.strict
? area.containsRect(bbox)
: area.isIntersectWithRect(bbox)
}
return false
}) as CellView[]
}
findEdgeViewsInArea(
rect: Rectangle.RectangleLike,
options: Renderer.FindViewsInAreaOptions = {},
) {
const area = Rectangle.create(rect)
findEdgeViewsFromPoint(p: Point.PointLike, threshold = 5) {
return this.model
.getEdges()
.map((edge) => this.findViewByCell(edge))
.filter((view: EdgeView) => {
if (view != null) {
const point = view.getClosestPoint(p)
if (point) {
return point.distance(p) <= threshold
}
}
return false
}) as EdgeView[]
}
findViewsInArea(
rect: Rectangle.RectangleLike,
options: { strict?: boolean; nodeOnly?: boolean } = {},
) {
const area = Rectangle.create(rect)
return this.model
.getCells()
.map((cell) => this.findViewByCell(cell))
.filter((view) => {
if (view) {
if (options.nodeOnly && !view.isNodeView()) {
return false
}
const bbox = Util.getBBox(view.container as SVGElement, {
target: this.view.stage,
})

View File

@ -31,6 +31,7 @@ export class Scheduler extends Disposable {
protected init() {
this.startListening()
this.renderViews(this.model.getCells())
}
protected startListening() {
@ -130,7 +131,7 @@ export class Scheduler extends Disposable {
setRenderArea(area?: Rectangle) {
this.renderArea = area
this.flushWaittingViews()
this.flushWaitingViews()
}
isViewMounted(view: CellView) {
@ -202,7 +203,7 @@ export class Scheduler extends Disposable {
}
let result = 0
if (this.isUpdateable(view)) {
if (this.isUpdatable(view)) {
result = this.updateView(view, flag, options)
viewItem.flag = result
} else {
@ -210,7 +211,7 @@ export class Scheduler extends Disposable {
result = this.updateView(view, flag, options)
viewItem.flag = result
} else {
viewItem.state = Scheduler.ViewState.WAITTING
viewItem.state = Scheduler.ViewState.WAITING
}
}
@ -258,9 +259,9 @@ export class Scheduler extends Disposable {
: this.queue.queueFlushSync()
}
protected flushWaittingViews() {
protected flushWaitingViews() {
Object.values(this.views).forEach((viewItem) => {
if (viewItem && viewItem.state === Scheduler.ViewState.WAITTING) {
if (viewItem && viewItem.state === Scheduler.ViewState.WAITING) {
const { view, flag, options } = viewItem
this.requestViewUpdate(
view,
@ -410,16 +411,21 @@ export class Scheduler extends Disposable {
}
protected createCellView(cell: Cell) {
const options = { graph: this.graph }
const createViewHook = this.graph.options.createCellView
if (createViewHook) {
const ret = FunctionExt.call(createViewHook, this.graph, cell)
if (ret || ret === null) {
return ret
if (ret) {
return new ret(cell, options) // eslint-disable-line new-cap
}
if (ret === null) {
// null means not render
return null
}
}
const view = cell.view
const options = { graph: this.graph }
if (view != null && typeof view === 'string') {
const def = CellView.registry.get(view)
@ -475,30 +481,23 @@ export class Scheduler extends Disposable {
return effectedEdges
}
protected isUpdateable(view: CellView) {
protected isUpdatable(view: CellView) {
if (view.isNodeView()) {
if (!this.renderArea) {
return true
if (this.renderArea) {
return this.renderArea.isIntersectWithRect(view.cell.getBBox())
}
const node = view.cell
return this.renderArea.isIntersectWithRect(node.getBBox())
return true
}
if (view.isEdgeView()) {
const edge = view.cell
const sourceCell = edge.getSourceCell()
const targetCell = edge.getTargetCell()
if (sourceCell) {
const sourceViewItem = this.views[sourceCell.id]
if (sourceViewItem && !this.isViewMounted(sourceViewItem.view)) {
return false
}
}
if (targetCell) {
const targetViewItem = this.views[targetCell.id]
if (targetViewItem && !this.isViewMounted(targetViewItem.view)) {
return false
}
if (this.renderArea && sourceCell && targetCell) {
return (
this.renderArea.isIntersectWithRect(sourceCell.getBBox()) ||
this.renderArea.isIntersectWithRect(targetCell.getBBox())
)
}
}
@ -526,7 +525,7 @@ export namespace Scheduler {
export enum ViewState {
CREATED,
MOUNTED,
WAITTING,
WAITING,
}
export interface View {
view: CellView

View File

@ -6,6 +6,7 @@
.@{x6-prefix}-graph {
position: relative;
overflow: hidden;
outline: none;
touch-action: none;

Some files were not shown because too many files have changed in this diff Show More