Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Add objects #33

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/lib/components/DashCanvas.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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;
Expand Down
6 changes: 6 additions & 0 deletions src/lib/fragments/DashCanvas.react.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
});
};
};


Expand Down