【发布时间】:2020-05-17 05:05:26
【问题描述】:
我正在尝试将 grid-guide 和 edgehandles cytoscape.js 扩展包含到我的 Angular7 项目中。它可以工作,但不像预期的那样(我认为),我无法在初始化但未启动时禁用绘图边缘句柄。
cytoscape 是通过 @types/cytoscape 导入的
网格指南:https://github.com/iVis-at-Bilkent/cytoscape.js-grid-guide 边缘句柄:https://github.com/cytoscape/cytoscape.js-edgehandles
目前通过 npm 导入扩展
我已尝试关注已发布的此问题,但并没有让我走得太远:How to use UI extension for Cytoscape.js in Typescript?
我尝试过使用 @types/cytoscape 推荐的自定义 typings.d.ts 文件(参见 index.d.ts 文件底部)
typings.d.ts:
declare module 'edgehandles-cyto' {
const ext: cytoscape.Ext;
export = ext;
};
And importing into the component:
import cytoscape = require('cytoscape'); //This works
//Importing jquery and grid-guide, works, but maybe not as intended
var jquery = require('jquery');
var gridGuide = require('cytoscape-grid-guide');
//Importing cytoscape extension, edgehandles, works, but not as intended
var edgehandles = require('cytoscape-edgehandles');
//Connected with cytoscape
gridGuide( cytoscape, jquery );
cytoscape.use(edgehandles);
//After cytoscape is initialized, trying to include these extensions
this.cy.gridGuide(options); //Options and defaults are already set
this.cy.edgehandles(defaults);
项目链接: https://stackblitz.com/edit/angular-cytoscape
预期的结果是用 this.cy.edgehandles('drawon'); 开始边缘句柄;
【问题讨论】:
标签: typescript typescript-typings angular7