已解决
antv/x6 键盘快捷键事件
来自网友在路上 193893提问 提问时间:2023-11-21 05:56:12阅读次数: 93
最佳答案 问答题库938位专家为你答疑解惑
antv/x6 键盘快捷键事件
- 引用插件
- 取消/重做
- 放大/缩小
- 复制/剪切/粘贴
引用插件
安装
npm install @antv/x6-plugin-selection --save
npm install @antv/x6-plugin-keyboard --save
npm install @antv/x6-plugin-clipboard --save
npm install @antv/x6-plugin-history --save
导入
import { Selection } from '@antv/x6-plugin-selection'
import { Keyboard } from '@antv/x6-plugin-keyboard'
import { Clipboard } from '@antv/x6-plugin-clipboard'
import { History } from '@antv/x6-plugin-history'
取消/重做
this.graph.bindKey(['meta+z', 'ctrl+z'], () => {if (this.graph.canUndo()) {this.graph.undo()}return false})this.graph.bindKey(['meta+y', 'ctrl+y'], () => {if (this.graph.canRedo()) {this.graph.redo()}return false})
放大/缩小
this.graph.bindKey(['ctrl+1', 'meta+1'], () => {const zoom = this.graph.zoom()if (zoom < 1.5) {this.graph.zoom(0.1)}})this.graph.bindKey(['ctrl+2', 'meta+2'], () => {const zoom = this.graph.zoom()if (zoom > 0.5) {this.graph.zoom(-0.1)}})
复制/剪切/粘贴
this.graph.bindKey(['meta+c', 'ctrl+c'], () => {const cells = this.graph.getSelectedCells()if (cells.length) {this.graph.copy(cells)}return false})this.graph.bindKey(['meta+x', 'ctrl+x'], () => {const cells = graph.getSelectedCells()if (cells.length) {graph.cut(cells)}return false})this.graph.bindKey(['meta+v', 'ctrl+v'], () => {if (!this.graph.isClipboardEmpty()) {const cells = this.graph.paste({ offset: 32 })this.graph.cleanSelection()this.graph.select(cells)}return false})
查看全文
99%的人还看了
相似问题
- IDEA中安装Docker插件实现远程访问Docker
- vscode使用插件KoroFileHeader添加注释
- Java实现的插件化策略模式
- WordPress画廊插件Envira Gallery v1.9.7河蟹版下载
- 【IDEA 使用easyAPI、easyYapi、Apifox helper等插件时,导出接口文档缺少代码字段注释的相关内容、校验规则的解决方法】
- Figma 插件学习(一)
- Portraiture2024PS/LR专用智能磨皮插件,AI算法美颜,提高P图效率
- 033-从零搭建微服务-日志插件(一)
- install YAPI MongoDB 备份mongo 安装yapi插件cross-request 笔记
- 验证码案例 —— Kaptcha 插件介绍 后端生成验证码,前端展示并进行session验证(带完整前后端源码)
猜你感兴趣
版权申明
本文"antv/x6 键盘快捷键事件":http://eshow365.cn/6-40943-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!