types.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import { Point } from "../types";
  2. type _ExcalidrawElementBase = Readonly<{
  3. id: string;
  4. x: number;
  5. y: number;
  6. strokeColor: string;
  7. backgroundColor: string;
  8. fillStyle: string;
  9. strokeWidth: number;
  10. roughness: number;
  11. opacity: number;
  12. width: number;
  13. height: number;
  14. seed: number;
  15. version: number;
  16. versionNonce: number;
  17. isDeleted: boolean;
  18. }>;
  19. export type ExcalidrawGenericElement = _ExcalidrawElementBase & {
  20. type: "selection" | "rectangle" | "diamond" | "ellipse";
  21. };
  22. /**
  23. * ExcalidrawElement should be JSON serializable and (eventually) contain
  24. * no computed data. The list of all ExcalidrawElements should be shareable
  25. * between peers and contain no state local to the peer.
  26. */
  27. export type ExcalidrawElement =
  28. | ExcalidrawGenericElement
  29. | ExcalidrawTextElement
  30. | ExcalidrawLinearElement;
  31. export type ExcalidrawTextElement = _ExcalidrawElementBase &
  32. Readonly<{
  33. type: "text";
  34. font: string;
  35. text: string;
  36. baseline: number;
  37. }>;
  38. export type ExcalidrawLinearElement = _ExcalidrawElementBase &
  39. Readonly<{
  40. type: "arrow" | "line";
  41. points: Point[];
  42. }>;
  43. export type PointerType = "mouse" | "pen" | "touch";