constants.ts 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import { FontFamily } from "./element/types";
  2. import cssVariables from "./css/variables.module.scss";
  3. export const APP_NAME = "Excalidraw";
  4. export const DRAGGING_THRESHOLD = 10; // px
  5. export const LINE_CONFIRM_THRESHOLD = 8; // px
  6. export const ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;
  7. export const ELEMENT_TRANSLATE_AMOUNT = 1;
  8. export const TEXT_TO_CENTER_SNAP_THRESHOLD = 30;
  9. export const SHIFT_LOCKING_ANGLE = Math.PI / 12;
  10. export const CURSOR_TYPE = {
  11. TEXT: "text",
  12. CROSSHAIR: "crosshair",
  13. GRABBING: "grabbing",
  14. POINTER: "pointer",
  15. MOVE: "move",
  16. AUTO: "",
  17. };
  18. export const POINTER_BUTTON = {
  19. MAIN: 0,
  20. WHEEL: 1,
  21. SECONDARY: 2,
  22. TOUCH: -1,
  23. };
  24. export enum EVENT {
  25. COPY = "copy",
  26. PASTE = "paste",
  27. CUT = "cut",
  28. KEYDOWN = "keydown",
  29. KEYUP = "keyup",
  30. MOUSE_MOVE = "mousemove",
  31. RESIZE = "resize",
  32. UNLOAD = "unload",
  33. BLUR = "blur",
  34. DRAG_OVER = "dragover",
  35. DROP = "drop",
  36. GESTURE_END = "gestureend",
  37. BEFORE_UNLOAD = "beforeunload",
  38. GESTURE_START = "gesturestart",
  39. GESTURE_CHANGE = "gesturechange",
  40. POINTER_MOVE = "pointermove",
  41. POINTER_UP = "pointerup",
  42. STATE_CHANGE = "statechange",
  43. WHEEL = "wheel",
  44. TOUCH_START = "touchstart",
  45. TOUCH_END = "touchend",
  46. HASHCHANGE = "hashchange",
  47. VISIBILITY_CHANGE = "visibilitychange",
  48. SCROLL = "scroll",
  49. }
  50. export const ENV = {
  51. TEST: "test",
  52. DEVELOPMENT: "development",
  53. };
  54. export const CLASSES = {
  55. SHAPE_ACTIONS_MENU: "App-menu__left",
  56. };
  57. // 1-based in case we ever do `if(element.fontFamily)`
  58. export const FONT_FAMILY = {
  59. 1: "Virgil",
  60. 2: "Helvetica",
  61. 3: "Cascadia",
  62. } as const;
  63. export const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
  64. export const DEFAULT_FONT_SIZE = 20;
  65. export const DEFAULT_FONT_FAMILY: FontFamily = 1;
  66. export const DEFAULT_TEXT_ALIGN = "left";
  67. export const DEFAULT_VERTICAL_ALIGN = "top";
  68. export const DEFAULT_VERSION = "{version}";
  69. export const CANVAS_ONLY_ACTIONS = ["selectAll"];
  70. export const GRID_SIZE = 20; // TODO make it configurable?
  71. export const MIME_TYPES = {
  72. excalidraw: "application/vnd.excalidraw+json",
  73. excalidrawlib: "application/vnd.excalidrawlib+json",
  74. };
  75. export const EXPORT_DATA_TYPES = {
  76. excalidraw: "excalidraw",
  77. excalidrawClipboard: "excalidraw/clipboard",
  78. excalidrawLibrary: "excalidrawlib",
  79. } as const;
  80. export const STORAGE_KEYS = {
  81. LOCAL_STORAGE_LIBRARY: "excalidraw-library",
  82. } as const;
  83. // time in milliseconds
  84. export const TAP_TWICE_TIMEOUT = 300;
  85. export const TOUCH_CTX_MENU_TIMEOUT = 500;
  86. export const TITLE_TIMEOUT = 10000;
  87. export const TOAST_TIMEOUT = 5000;
  88. export const VERSION_TIMEOUT = 30000;
  89. export const SCROLL_TIMEOUT = 100;
  90. export const ZOOM_STEP = 0.1;
  91. // Report a user inactive after IDLE_THRESHOLD milliseconds
  92. export const IDLE_THRESHOLD = 60_000;
  93. // Report a user active each ACTIVE_THRESHOLD milliseconds
  94. export const ACTIVE_THRESHOLD = 3_000;
  95. export const MODES = {
  96. VIEW: "viewMode",
  97. ZEN: "zenMode",
  98. GRID: "gridMode",
  99. };
  100. export const THEME_FILTER = cssVariables.themeFilter;
  101. export const URL_QUERY_KEYS = {
  102. addLibrary: "addLibrary",
  103. } as const;
  104. export const URL_HASH_KEYS = {
  105. addLibrary: "addLibrary",
  106. } as const;