
* Disable text selection * Set content-editable=plaintext-only to disable Touch Bar formatting buttons * Enlarge resize handle tap targets for pen/touch * Make the lock button a button in mobile mode * Use icons instead of Unicode characters; add an alternate toolbar for creating multipoint lines * Allow buttons to hide themselves * Fix heuristic for showing shape actions * Refactor icons * Fix label for edit button * Switch edit button icon * Remove lock button on mobile * Add language selector on mobile * Fix showing edit button on mobile * Fix showing edit button on mobile, part 2 * Fix handle touch regions * Fix scroll-back button position * Allow using the text tool on a text object to start editing it * Fix deletion of last point in line
72 lines
2.0 KiB
TypeScript
72 lines
2.0 KiB
TypeScript
import { AppState, FlooredNumber } from "./types";
|
|
import { getDateTime } from "./utils";
|
|
|
|
const DEFAULT_PROJECT_NAME = `excalidraw-${getDateTime()}`;
|
|
|
|
export function getDefaultAppState(): AppState {
|
|
return {
|
|
draggingElement: null,
|
|
resizingElement: null,
|
|
multiElement: null,
|
|
editingElement: null,
|
|
elementType: "selection",
|
|
elementLocked: false,
|
|
exportBackground: true,
|
|
currentItemStrokeColor: "#000000",
|
|
currentItemBackgroundColor: "transparent",
|
|
currentItemFillStyle: "hachure",
|
|
currentItemStrokeWidth: 1,
|
|
currentItemRoughness: 1,
|
|
currentItemOpacity: 100,
|
|
currentItemFont: "20px Virgil",
|
|
viewBackgroundColor: "#ffffff",
|
|
scrollX: 0 as FlooredNumber,
|
|
scrollY: 0 as FlooredNumber,
|
|
cursorX: 0,
|
|
cursorY: 0,
|
|
scrolledOutside: false,
|
|
name: DEFAULT_PROJECT_NAME,
|
|
isResizing: false,
|
|
selectionElement: null,
|
|
zoom: 1,
|
|
openedMenu: null,
|
|
lastPointerDownWith: "mouse",
|
|
};
|
|
}
|
|
|
|
export function clearAppStateForLocalStorage(appState: AppState) {
|
|
const {
|
|
draggingElement,
|
|
resizingElement,
|
|
multiElement,
|
|
editingElement,
|
|
selectionElement,
|
|
isResizing,
|
|
...exportedState
|
|
} = appState;
|
|
return exportedState;
|
|
}
|
|
|
|
export function clearAppStatePropertiesForHistory(
|
|
appState: AppState,
|
|
): Partial<AppState> {
|
|
return {
|
|
exportBackground: appState.exportBackground,
|
|
currentItemStrokeColor: appState.currentItemStrokeColor,
|
|
currentItemBackgroundColor: appState.currentItemBackgroundColor,
|
|
currentItemFillStyle: appState.currentItemFillStyle,
|
|
currentItemStrokeWidth: appState.currentItemStrokeWidth,
|
|
currentItemRoughness: appState.currentItemRoughness,
|
|
currentItemOpacity: appState.currentItemOpacity,
|
|
currentItemFont: appState.currentItemFont,
|
|
viewBackgroundColor: appState.viewBackgroundColor,
|
|
name: appState.name,
|
|
};
|
|
}
|
|
|
|
export function cleanAppStateForExport(appState: AppState) {
|
|
return {
|
|
viewBackgroundColor: appState.viewBackgroundColor,
|
|
};
|
|
}
|