Skip to content
Snippets Groups Projects
Commit 3cfa1f8d authored by Samuel Jugnet's avatar Samuel Jugnet
Browse files

wip link shape to colors

parent 4fb33fcd
No related branches found
No related tags found
1 merge request!10Draft: MigratingAnnotationCreation to MUI5.
Pipeline #1719 failed
......@@ -99,10 +99,7 @@ class AnnotationDrawing extends Component {
selectedShape.text = selectedShape.text.slice(0, -1);
} else {
// return if not a letter
if (e.key.length !== 1) {
return;
}
// return if special char
if (unnalowedKeys.includes(e.key)) {
......@@ -128,10 +125,18 @@ class AnnotationDrawing extends Component {
};
componentDidUpdate(prevProps) {
if (prevProps.activeTool === 'text' && this.props.activeTool !== 'text') {
console.log('did update', this.props.activeTool);
// check for selectined fhape, if colors are changesd we update the shape
// Remove global key press event listener
window.removeEventListener('keypress', this.handleKeyPress);
}
}
......@@ -401,6 +406,36 @@ class AnnotationDrawing extends Component {
const { windowId } = this.props;
const shape = shapes.find((shape) => shape.id === this.state.selectedShapeId);
if (shape) {
// if all the props are the same we don't update the shape
if (this.props.fillColor !== shape.fill || this.props.strokeColor !== shape.strokeColor || this.props.strokeWidth !== shape.strokeWidth) {
shape.fill = this.props.fillColor;
shape.strokeColor = this.props.strokeColor;
shape.strokeWidth = this.props.strokeWidth;
const index = shapes.findIndex((shape) => shape.id === this.state.selectedShapeId);
shapes[index] = shape;
this.setState({ shapes: shapes });
}
}
// potentiellement videoRef et windowId
return (
<Stage
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment