diff --git a/src/lib/components/DashCanvas.react.js b/src/lib/components/DashCanvas.react.js index c6c85eb..2aa0fa1 100644 --- a/src/lib/components/DashCanvas.react.js +++ b/src/lib/components/DashCanvas.react.js @@ -23,7 +23,7 @@ DashCanvas.defaultProps = { json_data: '', image_content: '', trigger: 0, width: 500, height: 500, scale: 1, lineWidth: 10, lineColor: 'red', tool: "pencil", zoom: 1, - goButtonTitle: 'Save', hide_buttons: [] + goButtonTitle: 'Save', hide_buttons: [],json_objects: '' }; DashCanvas.propTypes = { @@ -112,7 +112,14 @@ DashCanvas.propTypes = { * Dash-assigned callback that should be called whenever any of the * properties change */ - setProps: PropTypes.func + setProps: PropTypes.func, + + /** + * Like json_data,add objects like paths or images + * Use utils.parse_json.parse_jsonstring to parse + * this string. + */ + json_objects: PropTypes.string }; export const propTypes = DashCanvas.propTypes; diff --git a/src/lib/fragments/DashCanvas.react.js b/src/lib/fragments/DashCanvas.react.js index 05cd811..6f07969 100644 --- a/src/lib/fragments/DashCanvas.react.js +++ b/src/lib/fragments/DashCanvas.react.js @@ -107,6 +107,12 @@ export default class DashCanvas extends Component { sketch._fc.setZoom(this.props.zoom); }; + + if ((this.props.json_objects !== prevProps.json_objects)) { + this._sketch.fromJSON({ + 'objects':sketch.toJSON().objects.concat(JSON.parse(this.props.json_objects)) + }); + }; };