首发于 语雀文档

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

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

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

    获取画布

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

    获取当前节点

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

    获取当前节点的数据模型

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

    保存画布数据

    1. this.props.propsAPI.save()

    清除所选项

    1. this.props.propsAPI.currentPage.clearSelected()

    设置选中状态

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