mirror of
				https://github.com/excalidraw/excalidraw.git
				synced 2025-10-31 19:04:35 +01:00 
			
		
		
		
	Prevent re-assignment of elements (#121)
This commit is contained in:
		 Christopher Chedeau
					Christopher Chedeau
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							25aabdc4d1
						
					
				
				
					commit
					bd86f819df
				
			| @@ -26,7 +26,7 @@ type ExcalidrawTextElement = ExcalidrawElement & { | ||||
| const LOCAL_STORAGE_KEY = "excalidraw"; | ||||
| const LOCAL_STORAGE_KEY_STATE = "excalidraw-state"; | ||||
|  | ||||
| let elements = Array.of<ExcalidrawElement>(); | ||||
| const elements = Array.of<ExcalidrawElement>(); | ||||
|  | ||||
| // https://stackoverflow.com/questions/521295/seeding-the-random-number-generator-in-javascript/47593316#47593316 | ||||
| const LCG = (seed: number) => () => | ||||
| @@ -582,13 +582,13 @@ function restore() { | ||||
|     const savedState = localStorage.getItem(LOCAL_STORAGE_KEY_STATE); | ||||
|  | ||||
|     if (savedElements) { | ||||
|       elements = JSON.parse(savedElements); | ||||
|       elements.splice(0, elements.length, ...JSON.parse(savedElements)); | ||||
|       elements.forEach((element: ExcalidrawElement) => generateDraw(element)); | ||||
|     } | ||||
|  | ||||
|     return savedState ? JSON.parse(savedState) : null; | ||||
|   } catch (e) { | ||||
|     elements = []; | ||||
|     elements.splice(0, elements.length); | ||||
|     return null; | ||||
|   } | ||||
| } | ||||
| @@ -783,7 +783,7 @@ class App extends React.Component<{}, AppState> { | ||||
|  | ||||
|   private clearCanvas = () => { | ||||
|     if (window.confirm("This will clear the whole canvas. Are you sure?")) { | ||||
|       elements = []; | ||||
|       elements.splice(0, elements.length); | ||||
|       this.setState({ | ||||
|         viewBackgroundColor: "#ffffff", | ||||
|         scrollX: 0, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user