2021-02-24 19:52:17 +05:30
|
|
|
import cssVariables from "./css/variables.module.scss";
|
2021-04-04 15:57:14 +05:30
|
|
|
import { AppProps } from "./types";
|
2021-06-13 21:26:55 +05:30
|
|
|
import { FontFamilyValues } from "./element/types";
|
2020-06-25 21:21:27 +02:00
|
|
|
|
2020-12-22 11:34:06 +02:00
|
|
|
export const APP_NAME = "Excalidraw";
|
|
|
|
|
2021-02-14 14:43:23 +01:00
|
|
|
export const DRAGGING_THRESHOLD = 10; // px
|
|
|
|
export const LINE_CONFIRM_THRESHOLD = 8; // px
|
2020-03-07 10:20:38 -05:00
|
|
|
export const ELEMENT_SHIFT_TRANSLATE_AMOUNT = 5;
|
|
|
|
export const ELEMENT_TRANSLATE_AMOUNT = 1;
|
|
|
|
export const TEXT_TO_CENTER_SNAP_THRESHOLD = 30;
|
2020-05-23 17:45:05 +09:00
|
|
|
export const SHIFT_LOCKING_ANGLE = Math.PI / 12;
|
2020-03-07 10:20:38 -05:00
|
|
|
export const CURSOR_TYPE = {
|
|
|
|
TEXT: "text",
|
|
|
|
CROSSHAIR: "crosshair",
|
|
|
|
GRABBING: "grabbing",
|
2021-07-09 18:00:13 -04:00
|
|
|
GRAB: "grab",
|
2020-03-18 16:43:06 +01:00
|
|
|
POINTER: "pointer",
|
2020-08-26 17:37:44 +01:00
|
|
|
MOVE: "move",
|
|
|
|
AUTO: "",
|
2020-03-07 10:20:38 -05:00
|
|
|
};
|
|
|
|
export const POINTER_BUTTON = {
|
|
|
|
MAIN: 0,
|
|
|
|
WHEEL: 1,
|
|
|
|
SECONDARY: 2,
|
|
|
|
TOUCH: -1,
|
|
|
|
};
|
2020-04-12 06:12:02 +05:30
|
|
|
|
|
|
|
export enum EVENT {
|
|
|
|
COPY = "copy",
|
|
|
|
PASTE = "paste",
|
|
|
|
CUT = "cut",
|
|
|
|
KEYDOWN = "keydown",
|
|
|
|
KEYUP = "keyup",
|
|
|
|
MOUSE_MOVE = "mousemove",
|
|
|
|
RESIZE = "resize",
|
|
|
|
UNLOAD = "unload",
|
2021-10-07 13:19:40 +02:00
|
|
|
FOCUS = "focus",
|
2020-04-12 06:12:02 +05:30
|
|
|
BLUR = "blur",
|
|
|
|
DRAG_OVER = "dragover",
|
|
|
|
DROP = "drop",
|
|
|
|
GESTURE_END = "gestureend",
|
|
|
|
BEFORE_UNLOAD = "beforeunload",
|
|
|
|
GESTURE_START = "gesturestart",
|
|
|
|
GESTURE_CHANGE = "gesturechange",
|
|
|
|
POINTER_MOVE = "pointermove",
|
|
|
|
POINTER_UP = "pointerup",
|
2020-05-13 19:19:49 +02:00
|
|
|
STATE_CHANGE = "statechange",
|
2020-04-12 06:12:02 +05:30
|
|
|
WHEEL = "wheel",
|
|
|
|
TOUCH_START = "touchstart",
|
2020-06-02 18:41:40 +02:00
|
|
|
TOUCH_END = "touchend",
|
2020-07-10 07:16:28 +02:00
|
|
|
HASHCHANGE = "hashchange",
|
2021-02-04 11:55:43 +01:00
|
|
|
VISIBILITY_CHANGE = "visibilitychange",
|
2021-02-14 18:18:34 +05:30
|
|
|
SCROLL = "scroll",
|
2020-04-12 06:12:02 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
export const ENV = {
|
|
|
|
TEST: "test",
|
|
|
|
DEVELOPMENT: "development",
|
|
|
|
};
|
2020-04-12 16:24:52 +05:30
|
|
|
|
2020-04-12 15:57:57 +02:00
|
|
|
export const CLASSES = {
|
|
|
|
SHAPE_ACTIONS_MENU: "App-menu__left",
|
|
|
|
};
|
2020-05-27 15:14:50 +02:00
|
|
|
|
|
|
|
// 1-based in case we ever do `if(element.fontFamily)`
|
|
|
|
export const FONT_FAMILY = {
|
2021-06-13 21:26:55 +05:30
|
|
|
Virgil: 1,
|
|
|
|
Helvetica: 2,
|
|
|
|
Cascadia: 3,
|
|
|
|
};
|
2020-05-30 18:56:17 +05:30
|
|
|
|
2021-10-14 14:15:57 +05:30
|
|
|
export const THEME = {
|
|
|
|
LIGHT: "light",
|
|
|
|
DARK: "dark",
|
|
|
|
};
|
|
|
|
|
2020-07-19 21:14:45 +02:00
|
|
|
export const WINDOWS_EMOJI_FALLBACK_FONT = "Segoe UI Emoji";
|
|
|
|
|
2020-06-25 21:21:27 +02:00
|
|
|
export const DEFAULT_FONT_SIZE = 20;
|
2021-06-13 21:26:55 +05:30
|
|
|
export const DEFAULT_FONT_FAMILY: FontFamilyValues = FONT_FAMILY.Virgil;
|
2020-06-25 21:21:27 +02:00
|
|
|
export const DEFAULT_TEXT_ALIGN = "left";
|
|
|
|
export const DEFAULT_VERTICAL_ALIGN = "top";
|
2021-01-10 20:48:12 +02:00
|
|
|
export const DEFAULT_VERSION = "{version}";
|
2020-06-25 21:21:27 +02:00
|
|
|
|
2020-05-30 18:56:17 +05:30
|
|
|
export const CANVAS_ONLY_ACTIONS = ["selectAll"];
|
2020-06-24 00:24:52 +09:00
|
|
|
|
|
|
|
export const GRID_SIZE = 20; // TODO make it configurable?
|
2020-07-08 22:55:26 +02:00
|
|
|
|
2020-10-13 14:47:07 +02:00
|
|
|
export const MIME_TYPES = {
|
|
|
|
excalidraw: "application/vnd.excalidraw+json",
|
|
|
|
excalidrawlib: "application/vnd.excalidrawlib+json",
|
2021-10-21 22:05:48 +02:00
|
|
|
json: "application/json",
|
|
|
|
svg: "image/svg+xml",
|
|
|
|
png: "image/png",
|
|
|
|
jpg: "image/jpeg",
|
|
|
|
gif: "image/gif",
|
|
|
|
binary: "application/octet-stream",
|
2021-10-07 13:19:40 +02:00
|
|
|
} as const;
|
2020-10-30 21:01:41 +01:00
|
|
|
|
2021-03-20 20:20:47 +01:00
|
|
|
export const EXPORT_DATA_TYPES = {
|
|
|
|
excalidraw: "excalidraw",
|
|
|
|
excalidrawClipboard: "excalidraw/clipboard",
|
|
|
|
excalidrawLibrary: "excalidrawlib",
|
|
|
|
} as const;
|
|
|
|
|
2021-04-10 19:17:49 +02:00
|
|
|
export const EXPORT_SOURCE = window.location.origin;
|
|
|
|
|
2020-10-30 21:01:41 +01:00
|
|
|
export const STORAGE_KEYS = {
|
|
|
|
LOCAL_STORAGE_LIBRARY: "excalidraw-library",
|
2021-03-20 20:20:47 +01:00
|
|
|
} as const;
|
2020-12-05 20:00:53 +05:30
|
|
|
|
|
|
|
// time in milliseconds
|
2021-10-21 22:05:48 +02:00
|
|
|
export const IMAGE_RENDER_TIMEOUT = 500;
|
2020-12-05 20:00:53 +05:30
|
|
|
export const TAP_TWICE_TIMEOUT = 300;
|
|
|
|
export const TOUCH_CTX_MENU_TIMEOUT = 500;
|
2020-12-22 11:34:06 +02:00
|
|
|
export const TITLE_TIMEOUT = 10000;
|
2021-01-15 20:32:46 +05:30
|
|
|
export const TOAST_TIMEOUT = 5000;
|
2021-01-26 22:22:41 +02:00
|
|
|
export const VERSION_TIMEOUT = 30000;
|
2021-03-06 19:06:42 +05:30
|
|
|
export const SCROLL_TIMEOUT = 100;
|
2021-01-30 18:03:23 +01:00
|
|
|
export const ZOOM_STEP = 0.1;
|
2021-02-04 11:55:43 +01:00
|
|
|
|
|
|
|
// Report a user inactive after IDLE_THRESHOLD milliseconds
|
|
|
|
export const IDLE_THRESHOLD = 60_000;
|
|
|
|
// Report a user active each ACTIVE_THRESHOLD milliseconds
|
|
|
|
export const ACTIVE_THRESHOLD = 3_000;
|
2021-02-12 14:10:40 +05:30
|
|
|
|
|
|
|
export const MODES = {
|
|
|
|
VIEW: "viewMode",
|
|
|
|
ZEN: "zenMode",
|
|
|
|
GRID: "gridMode",
|
|
|
|
};
|
2021-02-24 19:52:17 +05:30
|
|
|
|
2021-03-13 18:58:06 +05:30
|
|
|
export const THEME_FILTER = cssVariables.themeFilter;
|
2021-03-26 18:10:43 +01:00
|
|
|
|
|
|
|
export const URL_QUERY_KEYS = {
|
|
|
|
addLibrary: "addLibrary",
|
|
|
|
} as const;
|
|
|
|
|
|
|
|
export const URL_HASH_KEYS = {
|
|
|
|
addLibrary: "addLibrary",
|
|
|
|
} as const;
|
2021-04-04 15:57:14 +05:30
|
|
|
|
|
|
|
export const DEFAULT_UI_OPTIONS: AppProps["UIOptions"] = {
|
|
|
|
canvasActions: {
|
|
|
|
changeViewBackgroundColor: true,
|
|
|
|
clearCanvas: true,
|
2021-05-29 02:56:25 +05:30
|
|
|
export: { saveFileToDisk: true },
|
2021-04-04 15:57:14 +05:30
|
|
|
loadScene: true,
|
2021-05-28 02:10:33 +05:30
|
|
|
saveToActiveFile: true,
|
2021-04-04 15:57:14 +05:30
|
|
|
theme: true,
|
2021-05-29 19:41:50 +05:30
|
|
|
saveAsImage: true,
|
2021-04-04 15:57:14 +05:30
|
|
|
},
|
|
|
|
};
|
2021-04-08 19:54:50 +02:00
|
|
|
|
|
|
|
export const MQ_MAX_WIDTH_PORTRAIT = 730;
|
|
|
|
export const MQ_MAX_WIDTH_LANDSCAPE = 1000;
|
|
|
|
export const MQ_MAX_HEIGHT_LANDSCAPE = 500;
|
2021-05-11 19:35:35 -07:00
|
|
|
|
|
|
|
export const MAX_DECIMALS_FOR_SVG_EXPORT = 2;
|
2021-05-30 15:31:12 +01:00
|
|
|
|
|
|
|
export const EXPORT_SCALES = [1, 2, 3];
|
|
|
|
export const DEFAULT_EXPORT_PADDING = 10; // px
|
2021-10-21 22:05:48 +02:00
|
|
|
|
|
|
|
export const DEFAULT_MAX_IMAGE_WIDTH_OR_HEIGHT = 1440;
|
|
|
|
|
|
|
|
export const ALLOWED_IMAGE_MIME_TYPES = [
|
|
|
|
MIME_TYPES.png,
|
|
|
|
MIME_TYPES.jpg,
|
|
|
|
MIME_TYPES.svg,
|
|
|
|
MIME_TYPES.gif,
|
|
|
|
] as const;
|
|
|
|
|
|
|
|
export const MAX_ALLOWED_FILE_BYTES = 2 * 1024 * 1024;
|
|
|
|
|
|
|
|
export const SVG_NS = "http://www.w3.org/2000/svg";
|
2021-11-07 14:33:21 +01:00
|
|
|
|
|
|
|
export const ENCRYPTION_KEY_BITS = 128;
|
2021-11-23 17:59:26 +01:00
|
|
|
|
|
|
|
export const VERSIONS = {
|
|
|
|
excalidraw: 2,
|
|
|
|
excalidrawLibrary: 2,
|
|
|
|
} as const;
|