constants.ts 2.2 KB

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