constants.ts 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. import { FontFamily } from "./element/types";
  2. export const DRAGGING_THRESHOLD = 10; // 10px
  3. export const LINE_CONFIRM_THRESHOLD = 10; // 10px
  4. export const ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;
  5. export const ELEMENT_TRANSLATE_AMOUNT = 1;
  6. export const TEXT_TO_CENTER_SNAP_THRESHOLD = 30;
  7. export const SHIFT_LOCKING_ANGLE = Math.PI / 12;
  8. export const CURSOR_TYPE = {
  9. TEXT: "text",
  10. CROSSHAIR: "crosshair",
  11. GRABBING: "grabbing",
  12. POINTER: "pointer",
  13. MOVE: "move",
  14. AUTO: "",
  15. };
  16. export const POINTER_BUTTON = {
  17. MAIN: 0,
  18. WHEEL: 1,
  19. SECONDARY: 2,
  20. TOUCH: -1,
  21. };
  22. export enum SCENE {
  23. INIT = "SCENE_INIT",
  24. UPDATE = "SCENE_UPDATE",
  25. }
  26. export enum EVENT {
  27. COPY = "copy",
  28. PASTE = "paste",
  29. CUT = "cut",
  30. KEYDOWN = "keydown",
  31. KEYUP = "keyup",
  32. MOUSE_MOVE = "mousemove",
  33. RESIZE = "resize",
  34. UNLOAD = "unload",
  35. BLUR = "blur",
  36. DRAG_OVER = "dragover",
  37. DROP = "drop",
  38. GESTURE_END = "gestureend",
  39. BEFORE_UNLOAD = "beforeunload",
  40. GESTURE_START = "gesturestart",
  41. GESTURE_CHANGE = "gesturechange",
  42. POINTER_MOVE = "pointermove",
  43. POINTER_UP = "pointerup",
  44. STATE_CHANGE = "statechange",
  45. WHEEL = "wheel",
  46. TOUCH_START = "touchstart",
  47. TOUCH_END = "touchend",
  48. HASHCHANGE = "hashchange",
  49. }
  50. export const ENV = {
  51. TEST: "test",
  52. DEVELOPMENT: "development",
  53. };
  54. export const BROADCAST = {
  55. SERVER_VOLATILE: "server-volatile-broadcast",
  56. SERVER: "server-broadcast",
  57. };
  58. export const CLASSES = {
  59. SHAPE_ACTIONS_MENU: "App-menu__left",
  60. };
  61. // 1-based in case we ever do `if(element.fontFamily)`
  62. export const FONT_FAMILY = {
  63. 1: "Virgil",
  64. 2: "Helvetica",
  65. 3: "Cascadia",
  66. } as const;
  67. export const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
  68. export const DEFAULT_FONT_SIZE = 20;
  69. export const DEFAULT_FONT_FAMILY: FontFamily = 1;
  70. export const DEFAULT_TEXT_ALIGN = "left";
  71. export const DEFAULT_VERTICAL_ALIGN = "top";
  72. export const CANVAS_ONLY_ACTIONS = ["selectAll"];
  73. export const GRID_SIZE = 20; // TODO make it configurable?
  74. export const LOCAL_STORAGE_KEY_COLLAB_FORCE_FLAG = "collabLinkForceLoadFlag";
  75. export const MIME_TYPES = {
  76. excalidraw: "application/vnd.excalidraw+json",
  77. excalidrawlib: "application/vnd.excalidrawlib+json",
  78. };