Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// 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();
if (this.props.onSelectedRegionsChanged) {
this.props.onSelectedRegionsChanged(this.getSelectedRegions());
}
} else { // When the canvas has been disabled
this.editor.AS.disable();
this.clearAllRegions();
this.editor.AS.setSelectionMode(SelectionMode.NONE);
}
}
}
project: IProject;
lockedTags: string[];
children?: ReactElement;
onAssetMetadataChanged?: (assetMetadata: IAssetMetadata) => void;
onSelectedRegionsChanged?: (regions: IRegion[]) => void;
}
export interface ICanvasState {
currentAsset: IAssetMetadata;
contentSource: ContentSource;
enabled: boolean;
}
export default class Canvas extends React.Component {
public static defaultProps: ICanvasProps = {
selectionMode: SelectionMode.NONE,
editorMode: EditorMode.Select,
selectedAsset: null,
project: null,
lockedTags: [],
};
public editor: Editor;
public state: ICanvasState = {
currentAsset: this.props.selectedAsset,
contentSource: null,
enabled: false,
};
private canvasZone: React.RefObject = React.createRef();
private clearConfirm: React.RefObject = React.createRef();
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:
this.canvas.current.copyRegions();
break;
case ToolbarItemName.CutRegions:
this.canvas.current.cutRegions();
break;
case ToolbarItemName.PasteRegions: