2020-03-17 20:55:40 +01:00
|
|
|
import {
|
|
|
|
PointerType,
|
|
|
|
ExcalidrawLinearElement,
|
2020-04-08 09:49:52 -07:00
|
|
|
NonDeletedExcalidrawElement,
|
|
|
|
NonDeleted,
|
2020-04-08 21:00:27 +01:00
|
|
|
TextAlign,
|
2020-05-14 17:04:33 +02:00
|
|
|
ExcalidrawElement,
|
2020-05-27 15:14:50 +02:00
|
|
|
FontFamily,
|
2020-05-26 13:07:46 -07:00
|
|
|
GroupId,
|
2020-03-17 20:55:40 +01:00
|
|
|
} from "./element/types";
|
2020-02-07 18:42:24 +01:00
|
|
|
import { SHAPES } from "./shapes";
|
2020-03-14 21:48:51 -07:00
|
|
|
import { Point as RoughPoint } from "roughjs/bin/geometry";
|
2020-04-12 16:24:52 +05:30
|
|
|
import { SocketUpdateDataSource } from "./data";
|
2020-06-01 11:35:44 +02:00
|
|
|
import { LinearElementEditor } from "./element/linearElementEditor";
|
2020-01-06 20:24:54 +04:00
|
|
|
|
2020-02-19 08:25:01 -08:00
|
|
|
export type FlooredNumber = number & { _brand: "FlooredNumber" };
|
2020-03-14 21:48:51 -07:00
|
|
|
export type Point = Readonly<RoughPoint>;
|
2020-02-19 08:25:01 -08:00
|
|
|
|
2020-01-06 20:24:54 +04:00
|
|
|
export type AppState = {
|
2020-03-26 18:28:26 +01:00
|
|
|
isLoading: boolean;
|
2020-04-03 12:50:51 +01:00
|
|
|
errorMessage: string | null;
|
2020-04-08 09:49:52 -07:00
|
|
|
draggingElement: NonDeletedExcalidrawElement | null;
|
|
|
|
resizingElement: NonDeletedExcalidrawElement | null;
|
|
|
|
multiElement: NonDeleted<ExcalidrawLinearElement> | null;
|
|
|
|
selectionElement: NonDeletedExcalidrawElement | null;
|
2020-01-19 23:32:24 +01:00
|
|
|
// element being edited, but not necessarily added to elements array yet
|
|
|
|
// (e.g. text element when typing into the input)
|
2020-04-08 09:49:52 -07:00
|
|
|
editingElement: NonDeletedExcalidrawElement | null;
|
2020-06-01 11:35:44 +02:00
|
|
|
editingLinearElement: LinearElementEditor | null;
|
2020-02-07 18:42:24 +01:00
|
|
|
elementType: typeof SHAPES[number]["value"];
|
2020-01-20 15:52:19 -08:00
|
|
|
elementLocked: boolean;
|
2020-01-06 20:24:54 +04:00
|
|
|
exportBackground: boolean;
|
2020-04-19 20:50:23 +01:00
|
|
|
shouldAddWatermark: boolean;
|
2020-01-06 20:24:54 +04:00
|
|
|
currentItemStrokeColor: string;
|
|
|
|
currentItemBackgroundColor: string;
|
2020-01-25 18:58:57 +01:00
|
|
|
currentItemFillStyle: string;
|
|
|
|
currentItemStrokeWidth: number;
|
2020-05-14 17:04:33 +02:00
|
|
|
currentItemStrokeStyle: ExcalidrawElement["strokeStyle"];
|
2020-01-25 18:58:57 +01:00
|
|
|
currentItemRoughness: number;
|
|
|
|
currentItemOpacity: number;
|
2020-05-27 15:14:50 +02:00
|
|
|
currentItemFontFamily: FontFamily;
|
|
|
|
currentItemFontSize: number;
|
2020-04-08 21:00:27 +01:00
|
|
|
currentItemTextAlign: TextAlign;
|
2020-01-06 20:24:54 +04:00
|
|
|
viewBackgroundColor: string;
|
2020-02-19 08:25:01 -08:00
|
|
|
scrollX: FlooredNumber;
|
|
|
|
scrollY: FlooredNumber;
|
2020-01-09 12:34:46 +01:00
|
|
|
cursorX: number;
|
|
|
|
cursorY: number;
|
2020-04-04 16:12:19 +01:00
|
|
|
cursorButton: "up" | "down";
|
2020-02-01 16:52:10 +00:00
|
|
|
scrolledOutside: boolean;
|
2020-01-06 20:24:54 +04:00
|
|
|
name: string;
|
2020-04-07 14:02:42 +01:00
|
|
|
username: string;
|
basic Socket.io implementation of collaborative editing (#879)
* Enable collaborative syncing for elements
* Don't fall back to local storage if using a room, as that is confusing
* Use remote socket server
* Send updates to new users when they join
* ~
* add mouse tracking
* enable collaboration, rooms, and mouse tracking
* fix syncing bugs and add a button to start syncing mid session
* enable collaboration, rooms, and mouse tracking
* fix syncing bugs and add a button to start syncing mid session
* Add Live button and app state to support tracking collaborator counts
* Enable collaborative syncing for elements
* add mouse tracking
* enable collaboration, rooms, and mouse tracking
* fix syncing bugs and add a button to start syncing mid session
* fix syncing bugs and add a button to start syncing mid session
* Add Live button and app state to support tracking collaborator counts
* prettier
* Fix bug with remote pointers not changing on scroll
* Enable collaborative syncing for elements
* add mouse tracking
* enable collaboration, rooms, and mouse tracking
* fix syncing bugs and add a button to start syncing mid session
* enable collaboration, rooms, and mouse tracking
* fix syncing bugs and add a button to start syncing mid session
* Add Live button and app state to support tracking collaborator counts
* enable collaboration, rooms, and mouse tracking
* fix syncing bugs and add a button to start syncing mid session
* fix syncing bugs and add a button to start syncing mid session
* Fix bug with remote pointers not changing on scroll
* remove UI for collaboration
* remove link
* clean up lingering unused UI
* set random IV passed per encrypted message, reduce room id length, refactored socket broadcasting API, rename room_id to room, removed throttling of pointer movement
* fix package.json conflict
2020-03-09 08:48:25 -07:00
|
|
|
isCollaborating: boolean;
|
2020-02-03 21:52:21 +04:00
|
|
|
isResizing: boolean;
|
2020-04-02 17:40:26 +09:00
|
|
|
isRotating: boolean;
|
2020-02-15 21:03:32 +01:00
|
|
|
zoom: number;
|
2020-03-01 14:39:03 -05:00
|
|
|
openMenu: "canvas" | "shape" | null;
|
2020-02-21 14:34:18 -05:00
|
|
|
lastPointerDownWith: PointerType;
|
2020-03-08 10:20:55 -07:00
|
|
|
selectedElementIds: { [id: string]: boolean };
|
2020-04-04 16:02:16 +02:00
|
|
|
collaborators: Map<
|
|
|
|
string,
|
|
|
|
{
|
|
|
|
pointer?: {
|
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
};
|
2020-04-04 16:12:19 +01:00
|
|
|
button?: "up" | "down";
|
2020-04-04 16:02:16 +02:00
|
|
|
selectedElementIds?: AppState["selectedElementIds"];
|
2020-04-07 14:02:42 +01:00
|
|
|
username?: string | null;
|
2020-04-04 16:02:16 +02:00
|
|
|
}
|
|
|
|
>;
|
2020-03-28 16:59:36 -07:00
|
|
|
shouldCacheIgnoreZoom: boolean;
|
2020-04-05 15:58:00 +03:00
|
|
|
showShortcutsDialog: boolean;
|
2020-04-25 18:43:02 +05:30
|
|
|
zenModeEnabled: boolean;
|
2020-05-26 13:07:46 -07:00
|
|
|
|
2020-05-30 22:48:57 +02:00
|
|
|
/** top-most selected groups (i.e. does not include nested groups) */
|
2020-05-26 13:07:46 -07:00
|
|
|
selectedGroupIds: { [groupId: string]: boolean };
|
2020-05-30 22:48:57 +02:00
|
|
|
/** group being edited when you drill down to its constituent element
|
|
|
|
(e.g. when you double-click on a group's element) */
|
2020-05-26 13:07:46 -07:00
|
|
|
editingGroupId: GroupId | null;
|
2020-01-06 20:24:54 +04:00
|
|
|
};
|
2020-02-21 08:17:20 -05:00
|
|
|
|
2020-03-08 19:25:16 -07:00
|
|
|
export type PointerCoords = Readonly<{
|
2020-02-21 08:17:20 -05:00
|
|
|
x: number;
|
|
|
|
y: number;
|
|
|
|
}>;
|
|
|
|
|
|
|
|
export type Gesture = {
|
2020-03-08 19:25:16 -07:00
|
|
|
pointers: Map<number, PointerCoords>;
|
2020-02-21 08:17:20 -05:00
|
|
|
lastCenter: { x: number; y: number } | null;
|
|
|
|
initialDistance: number | null;
|
|
|
|
initialScale: number | null;
|
|
|
|
};
|
2020-03-01 14:39:03 -05:00
|
|
|
|
|
|
|
export declare class GestureEvent extends UIEvent {
|
|
|
|
readonly rotation: number;
|
|
|
|
readonly scale: number;
|
|
|
|
}
|
2020-04-12 16:24:52 +05:30
|
|
|
|
|
|
|
export type SocketUpdateData = SocketUpdateDataSource[keyof SocketUpdateDataSource] & {
|
|
|
|
_brand: "socketUpdateData";
|
|
|
|
};
|