|
|
@ -44,7 +44,6 @@ import {
|
|
|
|
} from "../scene";
|
|
|
|
} from "../scene";
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
decryptAESGEM,
|
|
|
|
decryptAESGEM,
|
|
|
|
saveToLocalStorage,
|
|
|
|
|
|
|
|
loadScene,
|
|
|
|
loadScene,
|
|
|
|
loadFromBlob,
|
|
|
|
loadFromBlob,
|
|
|
|
SOCKET_SERVER,
|
|
|
|
SOCKET_SERVER,
|
|
|
@ -146,11 +145,7 @@ import {
|
|
|
|
isBindableElement,
|
|
|
|
isBindableElement,
|
|
|
|
} from "../element/typeChecks";
|
|
|
|
} from "../element/typeChecks";
|
|
|
|
import { actionFinalize, actionDeleteSelected } from "../actions";
|
|
|
|
import { actionFinalize, actionDeleteSelected } from "../actions";
|
|
|
|
import {
|
|
|
|
import { loadLibrary } from "../data/localStorage";
|
|
|
|
restoreUsernameFromLocalStorage,
|
|
|
|
|
|
|
|
saveUsernameToLocalStorage,
|
|
|
|
|
|
|
|
loadLibrary,
|
|
|
|
|
|
|
|
} from "../data/localStorage";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import throttle from "lodash.throttle";
|
|
|
|
import throttle from "lodash.throttle";
|
|
|
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
|
|
import { LinearElementEditor } from "../element/linearElementEditor";
|
|
|
@ -310,6 +305,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|
|
|
offsetLeft,
|
|
|
|
offsetLeft,
|
|
|
|
} = this.state;
|
|
|
|
} = this.state;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const { onUsernameChange } = this.props;
|
|
|
|
const canvasScale = window.devicePixelRatio;
|
|
|
|
const canvasScale = window.devicePixelRatio;
|
|
|
|
|
|
|
|
|
|
|
|
const canvasWidth = canvasDOMWidth * canvasScale;
|
|
|
|
const canvasWidth = canvasDOMWidth * canvasScale;
|
|
|
@ -335,13 +331,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|
|
|
onRoomCreate={this.openPortal}
|
|
|
|
onRoomCreate={this.openPortal}
|
|
|
|
onRoomDestroy={this.closePortal}
|
|
|
|
onRoomDestroy={this.closePortal}
|
|
|
|
onUsernameChange={(username) => {
|
|
|
|
onUsernameChange={(username) => {
|
|
|
|
if (this.props.onUsernameChange) {
|
|
|
|
onUsernameChange && onUsernameChange(username);
|
|
|
|
this.props.onUsernameChange(username);
|
|
|
|
this.setState({ username });
|
|
|
|
}
|
|
|
|
|
|
|
|
saveUsernameToLocalStorage(username);
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
username,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
onLockToggle={this.toggleLock}
|
|
|
|
onLockToggle={this.toggleLock}
|
|
|
|
onInsertShape={(elements) =>
|
|
|
|
onInsertShape={(elements) =>
|
|
|
@ -434,8 +425,6 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|
|
|
private onBlur = withBatchedUpdates(() => {
|
|
|
|
private onBlur = withBatchedUpdates(() => {
|
|
|
|
isHoldingSpace = false;
|
|
|
|
isHoldingSpace = false;
|
|
|
|
this.setState({ isBindingEnabled: true });
|
|
|
|
this.setState({ isBindingEnabled: true });
|
|
|
|
this.saveDebounced();
|
|
|
|
|
|
|
|
this.saveDebounced.flush();
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
private onUnload = () => {
|
|
|
|
private onUnload = () => {
|
|
|
@ -510,7 +499,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|
|
|
let isCollaborationScene = !!getCollaborationLinkData(window.location.href);
|
|
|
|
let isCollaborationScene = !!getCollaborationLinkData(window.location.href);
|
|
|
|
const isExternalScene = !!(id || jsonMatch || isCollaborationScene);
|
|
|
|
const isExternalScene = !!(id || jsonMatch || isCollaborationScene);
|
|
|
|
|
|
|
|
|
|
|
|
if (isExternalScene && !this.props.initialData) {
|
|
|
|
if (isExternalScene) {
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
this.shouldForceLoadScene(scene) ||
|
|
|
|
this.shouldForceLoadScene(scene) ||
|
|
|
|
window.confirm(t("alerts.loadSceneOverridePrompt"))
|
|
|
|
window.confirm(t("alerts.loadSceneOverridePrompt"))
|
|
|
@ -840,7 +829,6 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|
|
|
if (this.state.scrolledOutside !== scrolledOutside) {
|
|
|
|
if (this.state.scrolledOutside !== scrolledOutside) {
|
|
|
|
this.setState({ scrolledOutside: scrolledOutside });
|
|
|
|
this.setState({ scrolledOutside: scrolledOutside });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.saveDebounced();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
getDrawingVersion(this.scene.getElementsIncludingDeleted()) >
|
|
|
|
getDrawingVersion(this.scene.getElementsIncludingDeleted()) >
|
|
|
@ -1433,16 +1421,6 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
restoreUserName() {
|
|
|
|
|
|
|
|
const username = restoreUsernameFromLocalStorage();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (username !== null) {
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
|
|
username,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Input handling
|
|
|
|
// Input handling
|
|
|
|
|
|
|
|
|
|
|
|
private onKeyDown = withBatchedUpdates((event: KeyboardEvent) => {
|
|
|
|
private onKeyDown = withBatchedUpdates((event: KeyboardEvent) => {
|
|
|
@ -3679,10 +3657,6 @@ class App extends React.Component<ExcalidrawProps, AppState> {
|
|
|
|
this.setState({ shouldCacheIgnoreZoom: false });
|
|
|
|
this.setState({ shouldCacheIgnoreZoom: false });
|
|
|
|
}, 300);
|
|
|
|
}, 300);
|
|
|
|
|
|
|
|
|
|
|
|
private saveDebounced = debounce(() => {
|
|
|
|
|
|
|
|
saveToLocalStorage(this.scene.getElementsIncludingDeleted(), this.state);
|
|
|
|
|
|
|
|
}, 300);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private getCanvasOffsets() {
|
|
|
|
private getCanvasOffsets() {
|
|
|
|
if (this.excalidrawRef?.current) {
|
|
|
|
if (this.excalidrawRef?.current) {
|
|
|
|
const parentElement = this.excalidrawRef.current.parentElement;
|
|
|
|
const parentElement = this.excalidrawRef.current.parentElement;
|
|
|
|