fix: remove t from getDefaultAppState and allow name to be nullable (#7666)

* fix: remove t and allow name to be nullable

* pass name as required prop

* remove Unnamed

* pass name to excalidrawPlus as well for better type safe

* render once we have excalidrawAPI to avoid defaulting

* rename `getAppName` -> `getName` (temporary)

* stop preventing editing filenames when `props.name` supplied

* keep `name` as optional param for export functions

* keep `appState.name` on `props.name` state separate

* fix lint

* assertive first

* fix lint

* Add TODO

---------

Co-authored-by: dwelle <5153846+dwelle@users.noreply.github.com>
This commit is contained in:
Aakansha Doshi 2024-02-15 11:11:18 +05:30 committed by GitHub
parent 48c3465b19
commit 73bf50e8a8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 101 additions and 81 deletions

View file

@ -247,7 +247,7 @@ export interface AppState {
scrollY: number;
cursorButton: "up" | "down";
scrolledOutside: boolean;
name: string;
name: string | null;
isResizing: boolean;
isRotating: boolean;
zoom: Zoom;
@ -435,6 +435,7 @@ export interface ExcalidrawProps {
objectsSnapModeEnabled?: boolean;
libraryReturnUrl?: string;
theme?: Theme;
// @TODO come with better API before v0.18.0
name?: string;
renderCustomStats?: (
elements: readonly NonDeletedExcalidrawElement[],
@ -577,6 +578,7 @@ export type AppClassProperties = {
setOpenDialog: App["setOpenDialog"];
insertEmbeddableElement: App["insertEmbeddableElement"];
onMagicframeToolSelect: App["onMagicframeToolSelect"];
getName: App["getName"];
};
export type PointerDownState = Readonly<{
@ -651,10 +653,11 @@ export type ExcalidrawImperativeAPI = {
history: {
clear: InstanceType<typeof App>["resetHistory"];
};
scrollToContent: InstanceType<typeof App>["scrollToContent"];
getSceneElements: InstanceType<typeof App>["getSceneElements"];
getAppState: () => InstanceType<typeof App>["state"];
getFiles: () => InstanceType<typeof App>["files"];
getName: InstanceType<typeof App>["getName"];
scrollToContent: InstanceType<typeof App>["scrollToContent"];
registerAction: (action: Action) => void;
refresh: InstanceType<typeof App>["refresh"];
setToast: InstanceType<typeof App>["setToast"];