constants.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 EVENT {
  23. COPY = "copy",
  24. PASTE = "paste",
  25. CUT = "cut",
  26. KEYDOWN = "keydown",
  27. KEYUP = "keyup",
  28. MOUSE_MOVE = "mousemove",
  29. RESIZE = "resize",
  30. UNLOAD = "unload",
  31. BLUR = "blur",
  32. DRAG_OVER = "dragover",
  33. DROP = "drop",
  34. GESTURE_END = "gestureend",
  35. BEFORE_UNLOAD = "beforeunload",
  36. GESTURE_START = "gesturestart",
  37. GESTURE_CHANGE = "gesturechange",
  38. POINTER_MOVE = "pointermove",
  39. POINTER_UP = "pointerup",
  40. STATE_CHANGE = "statechange",
  41. WHEEL = "wheel",
  42. TOUCH_START = "touchstart",
  43. TOUCH_END = "touchend",
  44. HASHCHANGE = "hashchange",
  45. }
  46. export const ENV = {
  47. TEST: "test",
  48. DEVELOPMENT: "development",
  49. };
  50. export const CLASSES = {
  51. SHAPE_ACTIONS_MENU: "App-menu__left",
  52. };
  53. // 1-based in case we ever do `if(element.fontFamily)`
  54. export const FONT_FAMILY = {
  55. 1: "Virgil",
  56. 2: "Helvetica",
  57. 3: "Cascadia",
  58. } as const;
  59. export const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
  60. export const DEFAULT_FONT_SIZE = 20;
  61. export const DEFAULT_FONT_FAMILY: FontFamily = 1;
  62. export const DEFAULT_TEXT_ALIGN = "left";
  63. export const DEFAULT_VERTICAL_ALIGN = "top";
  64. export const CANVAS_ONLY_ACTIONS = ["selectAll"];
  65. export const GRID_SIZE = 20; // TODO make it configurable?
  66. export const MIME_TYPES = {
  67. excalidraw: "application/vnd.excalidraw+json",
  68. excalidrawlib: "application/vnd.excalidrawlib+json",
  69. };
  70. export const STORAGE_KEYS = {
  71. LOCAL_STORAGE_LIBRARY: "excalidraw-library",
  72. };
  73. // time in milliseconds
  74. export const TAP_TWICE_TIMEOUT = 300;
  75. export const TOUCH_CTX_MENU_TIMEOUT = 500;