Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

constants.ts 3.7KB

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