全网最详gg-editor教材-常用API

1,307 阅读1分钟

首发于 语雀文档

此篇文章,不做分类,工作忙,暂仅做收录,后期再分类。

凡是用 withPropsAPI 包裹过得组件,组件 props 中都会有 propsAPI 属性,这是 ggeditor 暴露的 API。

import withPropsAPI from "gg-editor"
console.log(this.props.propsAPI)


获取画布

this.props.propsAPI.currentPage
this.props.propsAPI.getGraph()


获取当前节点

this.props.propsAPI.getSelected()[0]


获取当前节点的数据模型

this.props.propsAPI.getSelected()[0].getModel()


保存画布数据

this.props.propsAPI.save()


清除所选项

this.props.propsAPI.currentPage.clearSelected()


设置选中状态

const node = this.props.propsAPI.find('节点Id')
this.props.propsAPI.currentPage.setSelected(node)