Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public componentDidUpdate = async (prevProps: Readonly, prevState: Readonly) => {
if (this.props.selectedAsset.asset.id !== prevProps.selectedAsset.asset.id) {
this.setState({ currentAsset: this.props.selectedAsset });
}
// Handle selection mode changes
if (this.props.selectionMode !== prevProps.selectionMode) {
const options = (this.props.selectionMode === SelectionMode.COPYRECT) ? this.template : null;
this.editor.AS.setSelectionMode({ mode: this.props.selectionMode, template: options });
}
// When the project tags change re-apply tags to regions
if (this.props.project.tags !== prevProps.project.tags) {
this.updateCanvasToolsRegions();
}
// Handles when the canvas is enabled & disabled
if (prevState.enabled !== this.state.enabled) {
// When the canvas is ready to display
if (this.state.enabled) {
this.refreshCanvasToolsRegions();
this.setContentSource(this.state.contentSource);
this.editor.AS.setSelectionMode(this.props.selectionMode);
this.editor.AS.enable();
switch (toolbarItem.props.name) {
case ToolbarItemName.DrawRectangle:
this.setState({
selectionMode: SelectionMode.RECT,
editorMode: EditorMode.Rectangle,
});
break;
case ToolbarItemName.DrawPolygon:
this.setState({
selectionMode: SelectionMode.POLYGON,
editorMode: EditorMode.Polygon,
});
break;
case ToolbarItemName.CopyRectangle:
this.setState({
selectionMode: SelectionMode.COPYRECT,
editorMode: EditorMode.CopyRect,
});
break;
case ToolbarItemName.SelectCanvas:
this.setState({
selectionMode: SelectionMode.NONE,
editorMode: EditorMode.Select,
});
break;
case ToolbarItemName.PreviousAsset:
await this.goToRootAsset(-1);
break;
case ToolbarItemName.NextAsset:
await this.goToRootAsset(1);
break;
case ToolbarItemName.CopyRegions: