constants.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import cssVariables from "./css/variables.module.scss";
  2. import { AppProps } from "./types";
  3. import { FontFamilyValues } from "./element/types";
  4. export const APP_NAME = "Excalidraw";
  5. export const DRAGGING_THRESHOLD = 10; // px
  6. export const LINE_CONFIRM_THRESHOLD = 8; // px
  7. export const ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;
  8. export const ELEMENT_TRANSLATE_AMOUNT = 1;
  9. export const TEXT_TO_CENTER_SNAP_THRESHOLD = 30;
  10. export const SHIFT_LOCKING_ANGLE = Math.PI / 12;
  11. export const CURSOR_TYPE = {
  12. TEXT: "text",
  13. CROSSHAIR: "crosshair",
  14. GRABBING: "grabbing",
  15. GRAB: "grab",
  16. POINTER: "pointer",
  17. MOVE: "move",
  18. AUTO: "",
  19. };
  20. export const POINTER_BUTTON = {
  21. MAIN: 0,
  22. WHEEL: 1,
  23. SECONDARY: 2,
  24. TOUCH: -1,
  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. FOCUS = "focus",
  36. BLUR = "blur",
  37. DRAG_OVER = "dragover",
  38. DROP = "drop",
  39. GESTURE_END = "gestureend",
  40. BEFORE_UNLOAD = "beforeunload",
  41. GESTURE_START = "gesturestart",
  42. GESTURE_CHANGE = "gesturechange",
  43. POINTER_MOVE = "pointermove",
  44. POINTER_UP = "pointerup",
  45. STATE_CHANGE = "statechange",
  46. WHEEL = "wheel",
  47. TOUCH_START = "touchstart",
  48. TOUCH_END = "touchend",
  49. HASHCHANGE = "hashchange",
  50. VISIBILITY_CHANGE = "visibilitychange",
  51. SCROLL = "scroll",
  52. }
  53. export const ENV = {
  54. TEST: "test",
  55. DEVELOPMENT: "development",
  56. };
  57. export const CLASSES = {
  58. SHAPE_ACTIONS_MENU: "App-menu__left",
  59. };
  60. // 1-based in case we ever do `if(element.fontFamily)`
  61. export const FONT_FAMILY = {
  62. Virgil: 1,
  63. Helvetica: 2,
  64. Cascadia: 3,
  65. };
  66. export const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
  67. export const DEFAULT_FONT_SIZE = 20;
  68. export const DEFAULT_FONT_FAMILY: FontFamilyValues = FONT_FAMILY.Virgil;
  69. export const DEFAULT_TEXT_ALIGN = "left";
  70. export const DEFAULT_VERTICAL_ALIGN = "top";
  71. export const DEFAULT_VERSION = "{version}";
  72. export const CANVAS_ONLY_ACTIONS = ["selectAll"];
  73. export const GRID_SIZE = 20; // TODO make it configurable?
  74. export const MIME_TYPES = {
  75. excalidraw: "application/vnd.excalidraw+json",
  76. excalidrawlib: "application/vnd.excalidrawlib+json",
  77. } as const;
  78. export const EXPORT_DATA_TYPES = {
  79. excalidraw: "excalidraw",
  80. excalidrawClipboard: "excalidraw/clipboard",
  81. excalidrawLibrary: "excalidrawlib",
  82. } as const;
  83. export const EXPORT_SOURCE = window.location.origin;
  84. export const STORAGE_KEYS = {
  85. LOCAL_STORAGE_LIBRARY: "excalidraw-library",
  86. } as const;
  87. // time in milliseconds
  88. export const TAP_TWICE_TIMEOUT = 300;
  89. export const TOUCH_CTX_MENU_TIMEOUT = 500;
  90. export const TITLE_TIMEOUT = 10000;
  91. export const TOAST_TIMEOUT = 5000;
  92. export const VERSION_TIMEOUT = 30000;
  93. export const SCROLL_TIMEOUT = 100;
  94. export const ZOOM_STEP = 0.1;
  95. // Report a user inactive after IDLE_THRESHOLD milliseconds
  96. export const IDLE_THRESHOLD = 60_000;
  97. // Report a user active each ACTIVE_THRESHOLD milliseconds
  98. export const ACTIVE_THRESHOLD = 3_000;
  99. export const MODES = {
  100. VIEW: "viewMode",
  101. ZEN: "zenMode",
  102. GRID: "gridMode",
  103. };
  104. export const THEME_FILTER = cssVariables.themeFilter;
  105. export const URL_QUERY_KEYS = {
  106. addLibrary: "addLibrary",
  107. } as const;
  108. export const URL_HASH_KEYS = {
  109. addLibrary: "addLibrary",
  110. } as const;
  111. export const DEFAULT_UI_OPTIONS: AppProps["UIOptions"] = {
  112. canvasActions: {
  113. changeViewBackgroundColor: true,
  114. clearCanvas: true,
  115. export: { saveFileToDisk: true },
  116. loadScene: true,
  117. saveToActiveFile: true,
  118. theme: true,
  119. saveAsImage: true,
  120. },
  121. };
  122. export const MQ_MAX_WIDTH_PORTRAIT = 730;
  123. export const MQ_MAX_WIDTH_LANDSCAPE = 1000;
  124. export const MQ_MAX_HEIGHT_LANDSCAPE = 500;
  125. export const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
  126. export const EXPORT_SCALES = [1, 2, 3];
  127. export const DEFAULT_EXPORT_PADDING = 10; // px