docstring_tokens
stringlengths
18
16.9k
code_tokens
stringlengths
75
1.81M
html_url
stringlengths
74
116
file_name
stringlengths
3
311
keep keep keep replace keep keep replace keep
<mask> }; <mask> const renderCommentIcons = () => { <mask> return Object.values(commentIcons).map((commentIcon) => { <mask> const appState = excalidrawRef.current.getAppState(); <mask> const { x, y } = sceneCoordsToViewportCoords( <mask> { sceneX: commentIcon.x, sceneY: commentIcon.y }, <mask> excalidrawRef.current.getAppState(), <mask> ); </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove const appState = excalidrawRef.current.getAppState(); </s> add const appState = excalidrawAPI.getAppState(); </s> remove const appstate = excalidrawRef.current.getAppState(); </s> add const appstate = excalidrawAPI.getAppState(); </s> remove excalidrawRef.current.getAppState(), </s> add excalidrawAPI.getAppState(), </s> remove const onHashChange = () => { const hash = new URLSearchParams(window.location.hash.slice(1)); const libraryUrl = hash.get("addLibrary"); if (libraryUrl) { excalidrawRef.current.importLibrary(libraryUrl, hash.get("token")); } }; window.addEventListener("hashchange", onHashChange, false); return () => { window.removeEventListener("hashchange", onHashChange); }; }, []); </s> add </s> add const [pointerData, setPointerData] = useState(null);
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> pointerDownState.onMove = onPointerMove; <mask> pointerDownState.onUp = onPointerUp; <mask> <mask> excalidrawRef.current.setCustomType("comment"); <mask> }} <mask> > <mask> <div className="comment-avatar"> <mask> <img src="doremon.png" alt="doremon" /> <mask> </div> </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> add <div style={{ display: "flex", gap: "1em", justifyContent: "center", marginTop: "1em", }} > <div>x: {pointerData?.pointer.x ?? 0}</div> <div>y: {pointerData?.pointer.y ?? 0}</div> </div> </s> remove ref={excalidrawRef} </s> add ref={(api) => setExcalidrawAPI(api)} </s> remove files: excalidrawRef.current.getFiles(), </s> add files: excalidrawAPI.getFiles(), </s> remove excalidrawRef.current.getAppState(), </s> add excalidrawAPI.getAppState(), </s> remove excalidrawRef.current.resetScene(); </s> add excalidrawAPI.resetScene(); </s> remove files: excalidrawRef.current.getFiles(), </s> add files: excalidrawAPI.getFiles(),
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep keep keep keep keep
<mask> setComment(null); <mask> }; <mask> <mask> const renderComment = () => { <mask> const appState = excalidrawRef.current.getAppState(); <mask> const { x, y } = sceneCoordsToViewportCoords( <mask> { sceneX: comment.x, sceneY: comment.y }, <mask> appState, <mask> ); <mask> let top = y - COMMENT_ICON_DIMENSION / 2 - appState.offsetTop; </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove const appState = excalidrawRef.current.getAppState(); </s> add const appState = excalidrawAPI.getAppState(); </s> remove excalidrawRef.current.getAppState(), </s> add excalidrawAPI.getAppState(), </s> remove const appstate = excalidrawRef.current.getAppState(); </s> add const appstate = excalidrawAPI.getAppState(); </s> remove excalidrawRef.current.getAppState(), </s> add excalidrawAPI.getAppState(), </s> add const [pointerData, setPointerData] = useState(null); </s> remove const onHashChange = () => { const hash = new URLSearchParams(window.location.hash.slice(1)); const libraryUrl = hash.get("addLibrary"); if (libraryUrl) { excalidrawRef.current.importLibrary(libraryUrl, hash.get("token")); } }; window.addEventListener("hashchange", onHashChange, false); return () => { window.removeEventListener("hashchange", onHashChange); }; }, []); </s> add
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep keep keep keep keep
<mask> </button> <mask> <button <mask> className="reset-scene" <mask> onClick={() => { <mask> excalidrawRef.current.resetScene(); <mask> }} <mask> > <mask> Reset Scene <mask> </button> <mask> <button </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove excalidrawRef.current.updateScene({ </s> add excalidrawAPI.updateLibrary({ </s> remove excalidrawRef.current.setActiveTool({ </s> add excalidrawAPI.setActiveTool({ </s> add <div style={{ display: "flex", gap: "1em", justifyContent: "center", marginTop: "1em", }} > <div>x: {pointerData?.pointer.x ?? 0}</div> <div>y: {pointerData?.pointer.y ?? 0}</div> </div> </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(),
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep keep keep keep keep
<mask> Reset Scene <mask> </button> <mask> <button <mask> onClick={() => { <mask> excalidrawRef.current.updateScene({ <mask> libraryItems: [ <mask> { <mask> status: "published", <mask> elements: initialData.libraryItems[0], <mask> }, </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove excalidrawRef.current.resetScene(); </s> add excalidrawAPI.resetScene(); </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove excalidrawRef.current.updateScene(contents.data); </s> add if (contents.type === MIME_TYPES.excalidraw) { excalidrawAPI.updateScene(contents.data); } else if (contents.type === MIME_TYPES.excalidrawlib) { excalidrawAPI.updateLibrary({ libraryItems: contents.data.libraryItems, openLibraryMenu: true, }); } </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> add import { AbortError } from "../errors"; import { t } from "../i18n"; import { useEffect, useRef } from "react"; import { URL_HASH_KEYS, URL_QUERY_KEYS, APP_NAME, EVENT } from "../constants";
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep replace
<mask> collaborators.set("id4", { <mask> username: "fallback", <mask> avatarUrl: "https://example.com", <mask> }); <mask> excalidrawRef.current.updateScene({ collaborators }); <mask> } else { <mask> excalidrawRef.current.updateScene({ </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove excalidrawRef.current.updateScene({ </s> add excalidrawAPI.updateLibrary({ </s> remove this.library .importLibrary(file) .then(() => { this.setState({ isLoading: false, }); </s> add await this.library .updateLibrary({ libraryItems: file, merge: true, openLibraryMenu: true, </s> remove excalidrawRef.current.updateScene(contents.data); </s> add if (contents.type === MIME_TYPES.excalidraw) { excalidrawAPI.updateScene(contents.data); } else if (contents.type === MIME_TYPES.excalidrawlib) { excalidrawAPI.updateLibrary({ libraryItems: contents.data.libraryItems, openLibraryMenu: true, }); } </s> remove this.setState({ isLoading: false, errorMessage: t("errors.importLibraryError"), }); </s> add this.setState({ errorMessage: t("errors.importLibraryError") }); </s> add } catch (error: any) { if (error?.name === "AbortError") { console.warn(error); return; } setAppState({ errorMessage: t("errors.importLibraryError") }); }
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep add keep keep keep keep keep
<mask> </button> <mask> </div> <mask> </div> <mask> <div className="excalidraw-wrapper"> <mask> <Excalidraw <mask> ref={(api) => setExcalidrawAPI(api)} <mask> initialData={initialStatePromiseRef.current.promise} </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove ref={excalidrawRef} </s> add ref={(api) => setExcalidrawAPI(api)} </s> remove excalidrawRef.current.setCustomType("comment"); </s> add excalidrawAPI.setActiveTool({ type: "custom", customType: "comment", }); </s> remove excalidrawRef.current.resetScene(); </s> add excalidrawAPI.resetScene(); </s> remove excalidrawRef.current.updateScene({ </s> add excalidrawAPI.updateLibrary({ </s> remove onPointerUpdate={(payload) => console.info(payload)} </s> add onPointerUpdate={(payload) => setPointerData(payload)} </s> remove excalidrawRef.current.getAppState(), </s> add excalidrawAPI.getAppState(),
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep replace keep keep keep keep replace keep keep keep
<mask> <Excalidraw <mask> ref={excalidrawRef} <mask> initialData={initialStatePromiseRef.current.promise} <mask> onChange={(elements, state) => { <mask> console.info("Elements :", elements, "State : ", state); <mask> }} <mask> onPointerUpdate={(payload) => console.info(payload)} <mask> onCollabButtonClick={() => <mask> window.alert("You clicked on collab button") <mask> } </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> add <div style={{ display: "flex", gap: "1em", justifyContent: "center", marginTop: "1em", }} > <div>x: {pointerData?.pointer.x ?? 0}</div> <div>y: {pointerData?.pointer.y ?? 0}</div> </div> </s> remove excalidrawRef.current.resetScene(); </s> add excalidrawAPI.resetScene(); </s> remove onClick={() => { importLibraryFromJSON(library) .catch(muteFSAbortError) .catch((error) => { console.error(error); setAppState({ errorMessage: t("errors.importLibraryError") }); </s> add onClick={async () => { try { await fileOpen({ description: "Excalidraw library files", // ToDo: Be over-permissive until https://bugs.webkit.org/show_bug.cgi?id=34442 // gets resolved. Else, iOS users cannot open `.excalidraw` files. /* extensions: [".json", ".excalidrawlib"], */ </s> add const [excalidrawAPI, setExcalidrawAPI] = useState(null); useHandleLibrary({ excalidrawAPI }); </s> remove /** * imports library (from blob or libraryItems), merging with current library * (attempting to remove duplicates) */ importLibrary( library: | Blob | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>, defaultStatus: LibraryItem["status"] = "unpublished", ): Promise<LibraryItems> { return this.setLibrary( () => new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } resolve(mergeLibraryItems(this.lastLibraryItems, libraryItems)); } catch (error) { reject(error); } }), ); } </s> add
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep keep keep keep keep
<mask> </label> <mask> <button <mask> onClick={async () => { <mask> const svg = await exportToSvg({ <mask> elements: excalidrawRef.current.getSceneElements(), <mask> appState: { <mask> ...initialData.appState, <mask> exportWithDarkMode, <mask> exportEmbedScene, <mask> width: 300, </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), appState: excalidrawRef.current.getAppState(), files: excalidrawRef.current.getFiles(), </s> add elements: excalidrawAPI.getSceneElements(), appState: excalidrawAPI.getAppState(), files: excalidrawAPI.getFiles(), </s> remove files: excalidrawRef.current.getFiles(), </s> add files: excalidrawAPI.getFiles(), </s> remove excalidrawRef.current.updateScene(contents.data); </s> add if (contents.type === MIME_TYPES.excalidraw) { excalidrawAPI.updateScene(contents.data); } else if (contents.type === MIME_TYPES.excalidrawlib) { excalidrawAPI.updateLibrary({ libraryItems: contents.data.libraryItems, openLibraryMenu: true, }); } </s> add if (!excalidrawAPI) { return; }
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep keep keep keep keep
<mask> width: 300, <mask> height: 100, <mask> }, <mask> embedScene: true, <mask> files: excalidrawRef.current.getFiles(), <mask> }); <mask> appRef.current.querySelector(".export-svg").innerHTML = <mask> svg.outerHTML; <mask> }} <mask> > </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove files: excalidrawRef.current.getFiles(), </s> add files: excalidrawAPI.getFiles(), </s> remove files: excalidrawRef.current.getFiles(), </s> add files: excalidrawAPI.getFiles(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), appState: excalidrawRef.current.getAppState(), files: excalidrawRef.current.getFiles(), </s> add elements: excalidrawAPI.getSceneElements(), appState: excalidrawAPI.getAppState(), files: excalidrawAPI.getFiles(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove excalidrawRef.current.setCustomType("comment"); </s> add excalidrawAPI.setActiveTool({ type: "custom", customType: "comment", });
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> <button <mask> onClick={async () => { <mask> const blob = await exportToBlob({ <mask> elements: excalidrawRef.current.getSceneElements(), <mask> mimeType: "image/png", <mask> appState: { <mask> ...initialData.appState, <mask> exportEmbedScene, <mask> exportWithDarkMode, </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), appState: excalidrawRef.current.getAppState(), files: excalidrawRef.current.getFiles(), </s> add elements: excalidrawAPI.getSceneElements(), appState: excalidrawAPI.getAppState(), files: excalidrawAPI.getFiles(), </s> remove files: excalidrawRef.current.getFiles(), </s> add files: excalidrawAPI.getFiles(), </s> remove excalidrawRef.current.updateScene(contents.data); </s> add if (contents.type === MIME_TYPES.excalidraw) { excalidrawAPI.updateScene(contents.data); } else if (contents.type === MIME_TYPES.excalidrawlib) { excalidrawAPI.updateLibrary({ libraryItems: contents.data.libraryItems, openLibraryMenu: true, }); } </s> add if (!excalidrawAPI) { return; }
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep keep keep keep keep
<mask> ...initialData.appState, <mask> exportEmbedScene, <mask> exportWithDarkMode, <mask> }, <mask> files: excalidrawRef.current.getFiles(), <mask> }); <mask> setBlobUrl(window.URL.createObjectURL(blob)); <mask> }} <mask> > <mask> Export to Blob </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove files: excalidrawRef.current.getFiles(), </s> add files: excalidrawAPI.getFiles(), </s> remove files: excalidrawRef.current.getFiles(), </s> add files: excalidrawAPI.getFiles(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), appState: excalidrawRef.current.getAppState(), files: excalidrawRef.current.getFiles(), </s> add elements: excalidrawAPI.getSceneElements(), appState: excalidrawAPI.getAppState(), files: excalidrawAPI.getFiles(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(),
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep replace keep keep keep keep replace keep
<mask> onClick={async () => { <mask> const canvas = await exportToCanvas({ <mask> elements: excalidrawRef.current.getSceneElements(), <mask> appState: { <mask> ...initialData.appState, <mask> exportWithDarkMode, <mask> }, <mask> files: excalidrawRef.current.getFiles(), <mask> }); </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(), </s> remove elements: excalidrawRef.current.getSceneElements(), appState: excalidrawRef.current.getAppState(), files: excalidrawRef.current.getFiles(), </s> add elements: excalidrawAPI.getSceneElements(), appState: excalidrawAPI.getAppState(), files: excalidrawAPI.getFiles(), </s> remove files: excalidrawRef.current.getFiles(), </s> add files: excalidrawAPI.getFiles(), </s> remove excalidrawRef.current.updateScene(contents.data); </s> add if (contents.type === MIME_TYPES.excalidraw) { excalidrawAPI.updateScene(contents.data); } else if (contents.type === MIME_TYPES.excalidrawlib) { excalidrawAPI.updateLibrary({ libraryItems: contents.data.libraryItems, openLibraryMenu: true, }); }
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/packages/excalidraw/example/App.js
keep keep keep keep replace keep keep keep keep keep
<mask> // ----------------------------------------------------------------------------- <mask> /** @deprecated legacy: do not use outside of migration paths */ <mask> export type LibraryItem_v1 = readonly NonDeleted<ExcalidrawElement>[]; <mask> /** @deprecated legacy: do not use outside of migration paths */ <mask> export type LibraryItems_v1 = readonly LibraryItem_v1[]; <mask> <mask> /** v2 library item */ <mask> export type LibraryItem = { <mask> id: string; <mask> status: "published" | "unpublished"; </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> add export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1; export type LibraryItemsSource = | (( currentLibraryItems: LibraryItems, ) => | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>; </s> remove /** * imports library (from blob or libraryItems), merging with current library * (attempting to remove duplicates) */ importLibrary( library: | Blob | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>, defaultStatus: LibraryItem["status"] = "unpublished", ): Promise<LibraryItems> { return this.setLibrary( () => new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } resolve(mergeLibraryItems(this.lastLibraryItems, libraryItems)); } catch (error) { reject(error); } }), ); } </s> add </s> remove libraryItems?: LibraryItems | LibraryItems_v1; </s> add libraryItems?: LibraryItems_anyVersion; </s> remove import { ImportedDataState } from "./types"; </s> add </s> remove import Library from "./library"; </s> add </s> remove export const importLibraryFromJSON = async (library: Library) => { const blob = await fileOpen({ description: "Excalidraw library files", // ToDo: Be over-permissive until https://bugs.webkit.org/show_bug.cgi?id=34442 // gets resolved. Else, iOS users cannot open `.excalidraw` files. /* extensions: [".json", ".excalidrawlib"], */ }); await library.importLibrary(blob); }; </s> add
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/types.ts
keep add keep keep keep keep keep keep
<mask> }; <mask> export type LibraryItems = readonly LibraryItem[]; <mask> // ----------------------------------------------------------------------------- <mask> <mask> // NOTE ready/readyPromise props are optional for host apps' sake (our own <mask> // implem guarantees existence) <mask> export type ExcalidrawAPIRefValue = <mask> | ExcalidrawImperativeAPI </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove export type LibraryItems_v1 = readonly LibraryItem_v1[]; </s> add type LibraryItems_v1 = readonly LibraryItem_v1[]; </s> add updateLibrary: InstanceType<typeof Library>["updateLibrary"]; </s> remove export const importLibraryFromJSON = async (library: Library) => { const blob = await fileOpen({ description: "Excalidraw library files", // ToDo: Be over-permissive until https://bugs.webkit.org/show_bug.cgi?id=34442 // gets resolved. Else, iOS users cannot open `.excalidraw` files. /* extensions: [".json", ".excalidrawlib"], */ }); await library.importLibrary(blob); }; </s> add </s> remove libraryItems?: LibraryItems | LibraryItems_v1; </s> add </s> remove libraryItems?: LibraryItems | LibraryItems_v1; </s> add libraryItems?: LibraryItems_anyVersion; </s> remove const hash = new URLSearchParams(window.location.hash.slice(1)); const libraryUrl = hash.get(URL_HASH_KEYS.addLibrary); if (libraryUrl) { // If hash changed and it contains library url, import it and replace // the url to its previous state (important in case of collaboration // and similar). // Using history API won't trigger another hashchange. window.history.replaceState({}, "", event.oldURL); excalidrawAPI.importLibrary(libraryUrl, hash.get("token")); } else { </s> add const libraryUrlTokens = parseLibraryTokensFromUrl(); if (!libraryUrlTokens) {
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/types.ts
keep keep keep keep replace keep keep keep keep keep
<mask> elements?: ImportedDataState["elements"]; <mask> appState?: ImportedDataState["appState"]; <mask> collaborators?: Map<string, Collaborator>; <mask> commitToHistory?: boolean; <mask> libraryItems?: LibraryItems | LibraryItems_v1; <mask> }; <mask> <mask> export enum UserIdleState { <mask> ACTIVE = "active", <mask> AWAY = "away", </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove libraryItems?: LibraryItems | LibraryItems_v1; </s> add libraryItems?: LibraryItems_anyVersion; </s> add export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1; export type LibraryItemsSource = | (( currentLibraryItems: LibraryItems, ) => | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>; </s> remove export type LibraryItems_v1 = readonly LibraryItem_v1[]; </s> add type LibraryItems_v1 = readonly LibraryItem_v1[]; </s> remove const excalidrawRef = useRef(null); </s> add </s> add import { AbortError } from "../errors"; import { t } from "../i18n"; import { useEffect, useRef } from "react"; import { URL_HASH_KEYS, URL_QUERY_KEYS, APP_NAME, EVENT } from "../constants"; </s> remove /** * imports library (from blob or libraryItems), merging with current library * (attempting to remove duplicates) */ importLibrary( library: | Blob | Required<ImportedDataState>["libraryItems"] | Promise<Required<ImportedDataState>["libraryItems"]>, defaultStatus: LibraryItem["status"] = "unpublished", ): Promise<LibraryItems> { return this.setLibrary( () => new Promise<LibraryItems>(async (resolve, reject) => { try { let libraryItems: LibraryItems; if (library instanceof Blob) { libraryItems = await loadLibraryFromBlob(library, defaultStatus); } else { libraryItems = restoreLibraryItems(await library, defaultStatus); } resolve(mergeLibraryItems(this.lastLibraryItems, libraryItems)); } catch (error) { reject(error); } }), ); } </s> add
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/types.ts
keep keep keep add keep keep keep keep keep
<mask> }>; <mask> <mask> export type ExcalidrawImperativeAPI = { <mask> updateScene: InstanceType<typeof App>["updateScene"]; <mask> resetScene: InstanceType<typeof App>["resetScene"]; <mask> getSceneElementsIncludingDeleted: InstanceType< <mask> typeof App <mask> >["getSceneElementsIncludingDeleted"]; <mask> history: { </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> remove importLibrary: InstanceType<typeof App>["importLibraryFromUrl"]; </s> add </s> add export type LibraryItems_anyVersion = LibraryItems | LibraryItems_v1; export type LibraryItemsSource = | (( currentLibraryItems: LibraryItems, ) => | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>) | Blob | LibraryItems_anyVersion | Promise<LibraryItems_anyVersion | Blob>; </s> remove import { ImportedDataState } from "./types"; </s> add </s> remove export type LibraryItems_v1 = readonly LibraryItem_v1[]; </s> add type LibraryItems_v1 = readonly LibraryItem_v1[]; </s> add import { AbortError } from "../errors"; import { t } from "../i18n"; import { useEffect, useRef } from "react"; import { URL_HASH_KEYS, URL_QUERY_KEYS, APP_NAME, EVENT } from "../constants"; </s> remove import { LibraryItems, LibraryItem } from "../types"; </s> add import { LibraryItems, LibraryItem, ExcalidrawImperativeAPI, LibraryItemsSource, } from "../types";
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/types.ts
keep keep keep keep replace keep keep keep keep keep
<mask> getSceneElements: InstanceType<typeof App>["getSceneElements"]; <mask> getAppState: () => InstanceType<typeof App>["state"]; <mask> getFiles: () => InstanceType<typeof App>["files"]; <mask> refresh: InstanceType<typeof App>["refresh"]; <mask> importLibrary: InstanceType<typeof App>["importLibraryFromUrl"]; <mask> setToastMessage: InstanceType<typeof App>["setToastMessage"]; <mask> addFiles: (data: BinaryFileData[]) => void; <mask> readyPromise: ResolvablePromise<ExcalidrawImperativeAPI>; <mask> ready: true; <mask> id: string; </s> feat: factor out url library init & switch to `updateLibrary` API (#5115) Co-authored-by: Aakansha Doshi <[email protected]> </s> add updateLibrary: InstanceType<typeof Library>["updateLibrary"]; </s> remove const onHashChange = () => { const hash = new URLSearchParams(window.location.hash.slice(1)); const libraryUrl = hash.get("addLibrary"); if (libraryUrl) { excalidrawRef.current.importLibrary(libraryUrl, hash.get("token")); } }; window.addEventListener("hashchange", onHashChange, false); return () => { window.removeEventListener("hashchange", onHashChange); }; }, []); </s> add </s> remove excalidrawRef.current.addFiles(imagesArray); </s> add excalidrawAPI.addFiles(imagesArray); </s> add }, [excalidrawAPI]); </s> add if (!excalidrawAPI) { return; } </s> remove elements: excalidrawRef.current.getSceneElements(), </s> add elements: excalidrawAPI.getSceneElements(),
https://github.com/excalidraw/excalidraw/commit/cad6097d604d891e94e397af6bec0d2f3d2eed9b
src/types.ts
keep keep keep replace replace replace keep keep keep keep replace keep keep keep keep
<mask> } <mask> }, <mask> "react-dom": { <mask> "version": "16.13.0", <mask> "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.13.0.tgz", <mask> "integrity": "sha512-y09d2c4cG220DzdlFkPTnVvGTszVvNpC73v+AaLGLHbkpy3SSgvYq8x0rNwPJ/Rk/CicTNgk0hbHNw1gMEZAXg==", <mask> "requires": { <mask> "loose-envify": "^1.1.0", <mask> "object-assign": "^4.1.1", <mask> "prop-types": "^15.6.2", <mask> "scheduler": "^0.19.0" <mask> } <mask> }, <mask> "react-error-overlay": { <mask> "version": "6.0.7", </s> Bump react-dom from 16.13.0 to 16.13.1 (#1137) Bumps [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom) from 16.13.0 to 16.13.1. - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v16.13.1/packages/react-dom) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> </s> remove "version": "0.19.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.0.tgz", "integrity": "sha512-xowbVaTPe9r7y7RUejcK73/j8tt2jfiyTednOvHbA8JoClvMYCp+r8QegLwK/n8zWQAtZb1fFnER4XLBZXrCxA==", </s> add "version": "0.19.1", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz", "integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==", </s> remove "react-dom": "16.13.0", </s> add "react-dom": "16.13.1",
https://github.com/excalidraw/excalidraw/commit/cb2b5d154d1eb34b7d0e8687eaf96f1aaea6f291
package-lock.json
keep keep keep keep replace replace replace keep keep keep keep keep
<mask> "xmlchars": "^2.1.1" <mask> } <mask> }, <mask> "scheduler": { <mask> "version": "0.19.0", <mask> "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.0.tgz", <mask> "integrity": "sha512-xowbVaTPe9r7y7RUejcK73/j8tt2jfiyTednOvHbA8JoClvMYCp+r8QegLwK/n8zWQAtZb1fFnER4XLBZXrCxA==", <mask> "requires": { <mask> "loose-envify": "^1.1.0", <mask> "object-assign": "^4.1.1" <mask> } <mask> }, </s> Bump react-dom from 16.13.0 to 16.13.1 (#1137) Bumps [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom) from 16.13.0 to 16.13.1. - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v16.13.1/packages/react-dom) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> </s> remove "scheduler": "^0.19.0" </s> add "scheduler": "^0.19.1" </s> remove "version": "16.13.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.13.0.tgz", "integrity": "sha512-y09d2c4cG220DzdlFkPTnVvGTszVvNpC73v+AaLGLHbkpy3SSgvYq8x0rNwPJ/Rk/CicTNgk0hbHNw1gMEZAXg==", </s> add "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.13.1.tgz", "integrity": "sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==", </s> remove "react-dom": "16.13.0", </s> add "react-dom": "16.13.1",
https://github.com/excalidraw/excalidraw/commit/cb2b5d154d1eb34b7d0e8687eaf96f1aaea6f291
package-lock.json
keep keep keep keep replace keep keep keep keep keep
<mask> "browser-nativefs": "0.4.0", <mask> "i18next-browser-languagedetector": "4.0.2", <mask> "nanoid": "2.1.11", <mask> "react": "16.13.1", <mask> "react-dom": "16.13.0", <mask> "react-scripts": "3.4.1", <mask> "roughjs": "4.0.4", <mask> "socket.io-client": "2.3.0", <mask> "stacktrace-js": "2.0.2" <mask> }, </s> Bump react-dom from 16.13.0 to 16.13.1 (#1137) Bumps [react-dom](https://github.com/facebook/react/tree/HEAD/packages/react-dom) from 16.13.0 to 16.13.1. - [Release notes](https://github.com/facebook/react/releases) - [Changelog](https://github.com/facebook/react/blob/master/CHANGELOG.md) - [Commits](https://github.com/facebook/react/commits/v16.13.1/packages/react-dom) Signed-off-by: dependabot-preview[bot] <[email protected]> Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> </s> remove "version": "0.19.0", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.0.tgz", "integrity": "sha512-xowbVaTPe9r7y7RUejcK73/j8tt2jfiyTednOvHbA8JoClvMYCp+r8QegLwK/n8zWQAtZb1fFnER4XLBZXrCxA==", </s> add "version": "0.19.1", "resolved": "https://registry.npmjs.org/scheduler/-/scheduler-0.19.1.tgz", "integrity": "sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA==", </s> remove "scheduler": "^0.19.0" </s> add "scheduler": "^0.19.1" </s> remove "version": "16.13.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.13.0.tgz", "integrity": "sha512-y09d2c4cG220DzdlFkPTnVvGTszVvNpC73v+AaLGLHbkpy3SSgvYq8x0rNwPJ/Rk/CicTNgk0hbHNw1gMEZAXg==", </s> add "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-16.13.1.tgz", "integrity": "sha512-81PIMmVLnCNLO/fFOQxdQkvEq/+Hfpv24XNJfpyZhTRfO0QcmQIF/PgCa1zCOj2w1hrn12MFLyaJ/G0+Mxtfag==",
https://github.com/excalidraw/excalidraw/commit/cb2b5d154d1eb34b7d0e8687eaf96f1aaea6f291
package.json
keep add keep keep keep keep keep keep
<mask> import { EXPORT_DATA_TYPES, MIME_TYPES } from "./constants"; <mask> import { isInitializedImageElement } from "./element/typeChecks"; <mask> <mask> type ElementsClipboard = { <mask> type: typeof EXPORT_DATA_TYPES.excalidrawClipboard; <mask> elements: ExcalidrawElement[]; <mask> files: BinaryFiles | undefined; <mask> }; </s> fix: support copying PNG to clipboard on Safari (#3746) </s> remove type: ExportType, </s> add type: Omit<ExportType, "backend">, </s> remove export const copyBlobToClipboardAsPng = async (blob: Blob) => { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob }), ]); </s> add export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => { let promise; try { // in Safari so far we need to construct the ClipboardItem synchronously // (i.e. in the same tick) otherwise browser will complain for lack of // user intent. Using a Promise ClipboardItem constructor solves this. // https://bugs.webkit.org/show_bug.cgi?id=222262 // // not await so that we can detect whether the thrown error likely relates // to a lack of support for the Promise ClipboardItem constructor promise = navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob, }), ]); } catch (error: any) { // if we're using a Promise ClipboardItem, let's try constructing // with resolution value instead if (isPromiseLike(blob)) { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: await blob, }), ]); } else { throw error; } } await promise; </s> add } else { tempCanvas.remove(); // shouldn't happen throw new Error("Unsupported export type"); </s> add const blob = canvasToBlob(tempCanvas); </s> add } finally { tempCanvas.remove(); </s> add let blob = await canvasToBlob(tempCanvas); tempCanvas.remove();
https://github.com/excalidraw/excalidraw/commit/cb6b7559b431a7bdc869c268532a4ac772cb388a
src/clipboard.ts
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> : { text: systemClipboard }; <mask> } <mask> }; <mask> <mask> export const copyBlobToClipboardAsPng = async (blob: Blob) => { <mask> await navigator.clipboard.write([ <mask> new window.ClipboardItem({ [MIME_TYPES.png]: blob }), <mask> ]); <mask> }; <mask> <mask> export const copyTextToSystemClipboard = async (text: string | null) => { <mask> let copied = false; <mask> if (probablySupportsClipboardWriteText) { </s> fix: support copying PNG to clipboard on Safari (#3746) </s> remove type: ExportType, </s> add type: Omit<ExportType, "backend">, </s> add import { isPromiseLike } from "./utils"; </s> add } else { tempCanvas.remove(); // shouldn't happen throw new Error("Unsupported export type"); </s> add const blob = canvasToBlob(tempCanvas); </s> add let blob = await canvasToBlob(tempCanvas); tempCanvas.remove(); </s> remove let blob = await canvasToBlob(tempCanvas); tempCanvas.remove(); </s> add
https://github.com/excalidraw/excalidraw/commit/cb6b7559b431a7bdc869c268532a4ac772cb388a
src/clipboard.ts
keep keep keep keep replace keep keep keep keep keep
<mask> export { loadFromBlob } from "./blob"; <mask> export { loadFromJSON, saveAsJSON } from "./json"; <mask> <mask> export const exportCanvas = async ( <mask> type: ExportType, <mask> elements: readonly NonDeletedExcalidrawElement[], <mask> appState: AppState, <mask> files: BinaryFiles, <mask> { <mask> exportBackground, </s> fix: support copying PNG to clipboard on Safari (#3746) </s> add import { isPromiseLike } from "./utils"; </s> remove export const copyBlobToClipboardAsPng = async (blob: Blob) => { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob }), ]); </s> add export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => { let promise; try { // in Safari so far we need to construct the ClipboardItem synchronously // (i.e. in the same tick) otherwise browser will complain for lack of // user intent. Using a Promise ClipboardItem constructor solves this. // https://bugs.webkit.org/show_bug.cgi?id=222262 // // not await so that we can detect whether the thrown error likely relates // to a lack of support for the Promise ClipboardItem constructor promise = navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob, }), ]); } catch (error: any) { // if we're using a Promise ClipboardItem, let's try constructing // with resolution value instead if (isPromiseLike(blob)) { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: await blob, }), ]); } else { throw error; } } await promise; </s> add } finally { tempCanvas.remove(); </s> add } else { tempCanvas.remove(); // shouldn't happen throw new Error("Unsupported export type"); </s> add const blob = canvasToBlob(tempCanvas); </s> add let blob = await canvasToBlob(tempCanvas); tempCanvas.remove();
https://github.com/excalidraw/excalidraw/commit/cb6b7559b431a7bdc869c268532a4ac772cb388a
src/data/index.ts
keep keep keep keep replace replace keep keep keep keep keep
<mask> exportPadding, <mask> }); <mask> tempCanvas.style.display = "none"; <mask> document.body.appendChild(tempCanvas); <mask> let blob = await canvasToBlob(tempCanvas); <mask> tempCanvas.remove(); <mask> <mask> if (type === "png") { <mask> if (appState.exportEmbedScene) { <mask> blob = await ( <mask> await import(/* webpackChunkName: "image" */ "./image") </s> fix: support copying PNG to clipboard on Safari (#3746) </s> add let blob = await canvasToBlob(tempCanvas); tempCanvas.remove(); </s> add const blob = canvasToBlob(tempCanvas); </s> remove export const copyBlobToClipboardAsPng = async (blob: Blob) => { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob }), ]); </s> add export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => { let promise; try { // in Safari so far we need to construct the ClipboardItem synchronously // (i.e. in the same tick) otherwise browser will complain for lack of // user intent. Using a Promise ClipboardItem constructor solves this. // https://bugs.webkit.org/show_bug.cgi?id=222262 // // not await so that we can detect whether the thrown error likely relates // to a lack of support for the Promise ClipboardItem constructor promise = navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob, }), ]); } catch (error: any) { // if we're using a Promise ClipboardItem, let's try constructing // with resolution value instead if (isPromiseLike(blob)) { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: await blob, }), ]); } else { throw error; } } await promise; </s> remove type: ExportType, </s> add type: Omit<ExportType, "backend">, </s> add import { isPromiseLike } from "./utils"; </s> add } finally { tempCanvas.remove();
https://github.com/excalidraw/excalidraw/commit/cb6b7559b431a7bdc869c268532a4ac772cb388a
src/data/index.ts
keep keep keep add keep keep keep keep
<mask> tempCanvas.style.display = "none"; <mask> document.body.appendChild(tempCanvas); <mask> <mask> if (type === "png") { <mask> if (appState.exportEmbedScene) { <mask> blob = await ( <mask> await import(/* webpackChunkName: "image" */ "./image") <mask> ).encodePngMetadata({ </s> fix: support copying PNG to clipboard on Safari (#3746) </s> remove let blob = await canvasToBlob(tempCanvas); tempCanvas.remove(); </s> add </s> add const blob = canvasToBlob(tempCanvas); </s> remove export const copyBlobToClipboardAsPng = async (blob: Blob) => { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob }), ]); </s> add export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => { let promise; try { // in Safari so far we need to construct the ClipboardItem synchronously // (i.e. in the same tick) otherwise browser will complain for lack of // user intent. Using a Promise ClipboardItem constructor solves this. // https://bugs.webkit.org/show_bug.cgi?id=222262 // // not await so that we can detect whether the thrown error likely relates // to a lack of support for the Promise ClipboardItem constructor promise = navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob, }), ]); } catch (error: any) { // if we're using a Promise ClipboardItem, let's try constructing // with resolution value instead if (isPromiseLike(blob)) { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: await blob, }), ]); } else { throw error; } } await promise; </s> remove type: ExportType, </s> add type: Omit<ExportType, "backend">, </s> add import { isPromiseLike } from "./utils"; </s> add } finally { tempCanvas.remove();
https://github.com/excalidraw/excalidraw/commit/cb6b7559b431a7bdc869c268532a4ac772cb388a
src/data/index.ts
keep keep add keep keep keep keep keep
<mask> }); <mask> } else if (type === "clipboard") { <mask> try { <mask> await copyBlobToClipboardAsPng(blob); <mask> } catch (error: any) { <mask> if (error.name === "CANVAS_POSSIBLY_TOO_BIG") { <mask> throw error; <mask> } </s> fix: support copying PNG to clipboard on Safari (#3746) </s> remove export const copyBlobToClipboardAsPng = async (blob: Blob) => { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob }), ]); </s> add export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => { let promise; try { // in Safari so far we need to construct the ClipboardItem synchronously // (i.e. in the same tick) otherwise browser will complain for lack of // user intent. Using a Promise ClipboardItem constructor solves this. // https://bugs.webkit.org/show_bug.cgi?id=222262 // // not await so that we can detect whether the thrown error likely relates // to a lack of support for the Promise ClipboardItem constructor promise = navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob, }), ]); } catch (error: any) { // if we're using a Promise ClipboardItem, let's try constructing // with resolution value instead if (isPromiseLike(blob)) { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: await blob, }), ]); } else { throw error; } } await promise; </s> remove let blob = await canvasToBlob(tempCanvas); tempCanvas.remove(); </s> add </s> add let blob = await canvasToBlob(tempCanvas); tempCanvas.remove(); </s> add } finally { tempCanvas.remove(); </s> add } else { tempCanvas.remove(); // shouldn't happen throw new Error("Unsupported export type"); </s> add import { isPromiseLike } from "./utils";
https://github.com/excalidraw/excalidraw/commit/cb6b7559b431a7bdc869c268532a4ac772cb388a
src/data/index.ts
keep add keep keep keep keep keep
<mask> } <mask> throw new Error(t("alerts.couldNotCopyToClipboard")); <mask> } <mask> } else { <mask> tempCanvas.remove(); <mask> // shouldn't happen <mask> throw new Error("Unsupported export type"); </s> fix: support copying PNG to clipboard on Safari (#3746) </s> add } else { tempCanvas.remove(); // shouldn't happen throw new Error("Unsupported export type"); </s> remove export const copyBlobToClipboardAsPng = async (blob: Blob) => { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob }), ]); </s> add export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => { let promise; try { // in Safari so far we need to construct the ClipboardItem synchronously // (i.e. in the same tick) otherwise browser will complain for lack of // user intent. Using a Promise ClipboardItem constructor solves this. // https://bugs.webkit.org/show_bug.cgi?id=222262 // // not await so that we can detect whether the thrown error likely relates // to a lack of support for the Promise ClipboardItem constructor promise = navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob, }), ]); } catch (error: any) { // if we're using a Promise ClipboardItem, let's try constructing // with resolution value instead if (isPromiseLike(blob)) { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: await blob, }), ]); } else { throw error; } } await promise; </s> add const blob = canvasToBlob(tempCanvas); </s> remove type: ExportType, </s> add type: Omit<ExportType, "backend">, </s> add import { isPromiseLike } from "./utils"; </s> add let blob = await canvasToBlob(tempCanvas); tempCanvas.remove();
https://github.com/excalidraw/excalidraw/commit/cb6b7559b431a7bdc869c268532a4ac772cb388a
src/data/index.ts
keep keep keep add keep keep
<mask> throw new Error(t("alerts.couldNotCopyToClipboard")); <mask> } finally { <mask> tempCanvas.remove(); <mask> } <mask> } <mask> }; </s> fix: support copying PNG to clipboard on Safari (#3746) </s> add } finally { tempCanvas.remove(); </s> remove export const copyBlobToClipboardAsPng = async (blob: Blob) => { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob }), ]); </s> add export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => { let promise; try { // in Safari so far we need to construct the ClipboardItem synchronously // (i.e. in the same tick) otherwise browser will complain for lack of // user intent. Using a Promise ClipboardItem constructor solves this. // https://bugs.webkit.org/show_bug.cgi?id=222262 // // not await so that we can detect whether the thrown error likely relates // to a lack of support for the Promise ClipboardItem constructor promise = navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob, }), ]); } catch (error: any) { // if we're using a Promise ClipboardItem, let's try constructing // with resolution value instead if (isPromiseLike(blob)) { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: await blob, }), ]); } else { throw error; } } await promise; </s> add import { isPromiseLike } from "./utils"; </s> add const blob = canvasToBlob(tempCanvas); </s> remove type: ExportType, </s> add type: Omit<ExportType, "backend">, </s> add let blob = await canvasToBlob(tempCanvas); tempCanvas.remove();
https://github.com/excalidraw/excalidraw/commit/cb6b7559b431a7bdc869c268532a4ac772cb388a
src/data/index.ts
keep keep keep keep replace keep keep keep keep keep
<mask> "couldNotCreateShareableLinkTooBig": "Couldn't create shareable link: the scene is too big", <mask> "couldNotLoadInvalidFile": "Couldn't load invalid file", <mask> "importBackendFailed": "Importing from backend failed.", <mask> "cannotExportEmptyCanvas": "Cannot export empty canvas.", <mask> "couldNotCopyToClipboard": "Couldn't copy to clipboard. Try using Chrome browser.", <mask> "decryptFailed": "Couldn't decrypt data.", <mask> "uploadedSecurly": "The upload has been secured with end-to-end encryption, which means that Excalidraw server and third parties can't read the content.", <mask> "loadSceneOverridePrompt": "Loading external drawing will replace your existing content. Do you wish to continue?", <mask> "collabStopOverridePrompt": "Stopping the session will overwrite your previous, locally stored drawing. Are you sure?\n\n(If you want to keep your local drawing, simply close the browser tab instead.)", <mask> "errorLoadingLibrary": "There was an error loading the third party library.", </s> fix: support copying PNG to clipboard on Safari (#3746) </s> remove export const copyBlobToClipboardAsPng = async (blob: Blob) => { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob }), ]); </s> add export const copyBlobToClipboardAsPng = async (blob: Blob | Promise<Blob>) => { let promise; try { // in Safari so far we need to construct the ClipboardItem synchronously // (i.e. in the same tick) otherwise browser will complain for lack of // user intent. Using a Promise ClipboardItem constructor solves this. // https://bugs.webkit.org/show_bug.cgi?id=222262 // // not await so that we can detect whether the thrown error likely relates // to a lack of support for the Promise ClipboardItem constructor promise = navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: blob, }), ]); } catch (error: any) { // if we're using a Promise ClipboardItem, let's try constructing // with resolution value instead if (isPromiseLike(blob)) { await navigator.clipboard.write([ new window.ClipboardItem({ [MIME_TYPES.png]: await blob, }), ]); } else { throw error; } } await promise; </s> remove type: ExportType, </s> add type: Omit<ExportType, "backend">, </s> add import { isPromiseLike } from "./utils"; </s> add } finally { tempCanvas.remove(); </s> add } else { tempCanvas.remove(); // shouldn't happen throw new Error("Unsupported export type"); </s> add const blob = canvasToBlob(tempCanvas);
https://github.com/excalidraw/excalidraw/commit/cb6b7559b431a7bdc869c268532a4ac772cb388a
src/locales/en.json
keep keep keep add keep keep keep keep
<mask> </div> <mask> ); <mask> } <mask> <mask> const colors = { <mask> // Shade 0 <mask> canvasBackground: [ <mask> "#FFFFFF", </s> Open colors (#378) * Add open colors * More colors * Update colors * Shade 0 </s> add // Shade 0 </s> remove "#DEE6EF", "#FCEAD8", "#F9E0E0", "#E6F1F1", "#E0EDDF", "#FBF5DD", "#F0E6ED", "#FFEDEF", "#EDE5E1", "#F2F0EF", "#FFFFFF" </s> add "#FFFFFF", "#F8F9FA", "#F1F3F5", "#FFF5F5", "#FFF0F6", "#F8F0FC", "#F3F0FF", "#EDF2FF", "#E7F5FF", "#E3FAFC", "#E6FCF5", "#EBFBEE", "#F4FCE3", "#FFF9DB", "#FFF4E6" </s> add // Shade 9 </s> add // Shade 6 </s> remove "#4E79A7", "#F28E2C", "#E15759", "#76B7B2", "#59A14F", "#EDC949", "#AF7AA1", "#FF9DA7", "#9C755F", "#BAB0AB", "transparent" </s> add "transparent", "#CED4DA", "#868E96", "#FA5252", "#E64980", "#BE4BDB", "#7950F2", "#4C6EF5", "#228BE6", "#15AABF", "#12B886", "#40C057", "#82C91E", "#FAB005", "#FD7E14" </s> remove "#324E6B", "#9B5B1D", "#903839", "#4C7572", "#396733", "#AD9336", "#805976", "#BA737A", "#725646", "#88817D", "#000000" </s> add "#000000", "#343A40", "#495057", "#C92A2A", "#A61E4D", "#862E9C", "#5F3DC4", "#364FC7", "#1864AB", "#0B7285", "#087F5B", "#2B8A3E", "#5C940D", "#E67700", "#D9480F"
https://github.com/excalidraw/excalidraw/commit/cb8d866c33eceb82c8d85d1bbe55da463f32b592
src/components/ColorPicker.tsx
keep keep keep add keep keep keep keep keep keep
<mask> } <mask> <mask> // https://yeun.github.io/open-color/ <mask> const colors = { <mask> canvasBackground: [ <mask> "#FFFFFF", <mask> "#F8F9FA", <mask> "#F1F3F5", <mask> "#FFF5F5", <mask> "#FFF0F6", </s> Open colors (#378) * Add open colors * More colors * Update colors * Shade 0 </s> remove "#DEE6EF", "#FCEAD8", "#F9E0E0", "#E6F1F1", "#E0EDDF", "#FBF5DD", "#F0E6ED", "#FFEDEF", "#EDE5E1", "#F2F0EF", "#FFFFFF" </s> add "#FFFFFF", "#F8F9FA", "#F1F3F5", "#FFF5F5", "#FFF0F6", "#F8F0FC", "#F3F0FF", "#EDF2FF", "#E7F5FF", "#E3FAFC", "#E6FCF5", "#EBFBEE", "#F4FCE3", "#FFF9DB", "#FFF4E6" </s> add // https://yeun.github.io/open-color/ </s> add // Shade 9 </s> add // Shade 6 </s> remove "#4E79A7", "#F28E2C", "#E15759", "#76B7B2", "#59A14F", "#EDC949", "#AF7AA1", "#FF9DA7", "#9C755F", "#BAB0AB", "transparent" </s> add "transparent", "#CED4DA", "#868E96", "#FA5252", "#E64980", "#BE4BDB", "#7950F2", "#4C6EF5", "#228BE6", "#15AABF", "#12B886", "#40C057", "#82C91E", "#FAB005", "#FD7E14" </s> remove "#324E6B", "#9B5B1D", "#903839", "#4C7572", "#396733", "#AD9336", "#805976", "#BA737A", "#725646", "#88817D", "#000000" </s> add "#000000", "#343A40", "#495057", "#C92A2A", "#A61E4D", "#862E9C", "#5F3DC4", "#364FC7", "#1864AB", "#0B7285", "#087F5B", "#2B8A3E", "#5C940D", "#E67700", "#D9480F"
https://github.com/excalidraw/excalidraw/commit/cb8d866c33eceb82c8d85d1bbe55da463f32b592
src/components/ColorPicker.tsx
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> } <mask> <mask> const colors = { <mask> canvasBackground: [ <mask> "#DEE6EF", <mask> "#FCEAD8", <mask> "#F9E0E0", <mask> "#E6F1F1", <mask> "#E0EDDF", <mask> "#FBF5DD", <mask> "#F0E6ED", <mask> "#FFEDEF", <mask> "#EDE5E1", <mask> "#F2F0EF", <mask> "#FFFFFF" <mask> ], <mask> elementBackground: [ <mask> "#4E79A7", <mask> "#F28E2C", <mask> "#E15759", </s> Open colors (#378) * Add open colors * More colors * Update colors * Shade 0 </s> remove "#4E79A7", "#F28E2C", "#E15759", "#76B7B2", "#59A14F", "#EDC949", "#AF7AA1", "#FF9DA7", "#9C755F", "#BAB0AB", "transparent" </s> add "transparent", "#CED4DA", "#868E96", "#FA5252", "#E64980", "#BE4BDB", "#7950F2", "#4C6EF5", "#228BE6", "#15AABF", "#12B886", "#40C057", "#82C91E", "#FAB005", "#FD7E14" </s> add // https://yeun.github.io/open-color/ </s> add // Shade 0 </s> add // Shade 6 </s> add // Shade 9 </s> remove "#324E6B", "#9B5B1D", "#903839", "#4C7572", "#396733", "#AD9336", "#805976", "#BA737A", "#725646", "#88817D", "#000000" </s> add "#000000", "#343A40", "#495057", "#C92A2A", "#A61E4D", "#862E9C", "#5F3DC4", "#364FC7", "#1864AB", "#0B7285", "#087F5B", "#2B8A3E", "#5C940D", "#E67700", "#D9480F"
https://github.com/excalidraw/excalidraw/commit/cb8d866c33eceb82c8d85d1bbe55da463f32b592
src/components/ColorPicker.tsx
keep keep keep add keep keep keep keep keep
<mask> "#F4FCE3", <mask> "#FFF9DB", <mask> "#FFF4E6" <mask> ], <mask> elementBackground: [ <mask> "transparent", <mask> "#CED4DA", <mask> "#868E96", <mask> "#FA5252", </s> Open colors (#378) * Add open colors * More colors * Update colors * Shade 0 </s> remove "#4E79A7", "#F28E2C", "#E15759", "#76B7B2", "#59A14F", "#EDC949", "#AF7AA1", "#FF9DA7", "#9C755F", "#BAB0AB", "transparent" </s> add "transparent", "#CED4DA", "#868E96", "#FA5252", "#E64980", "#BE4BDB", "#7950F2", "#4C6EF5", "#228BE6", "#15AABF", "#12B886", "#40C057", "#82C91E", "#FAB005", "#FD7E14" </s> remove "#DEE6EF", "#FCEAD8", "#F9E0E0", "#E6F1F1", "#E0EDDF", "#FBF5DD", "#F0E6ED", "#FFEDEF", "#EDE5E1", "#F2F0EF", "#FFFFFF" </s> add "#FFFFFF", "#F8F9FA", "#F1F3F5", "#FFF5F5", "#FFF0F6", "#F8F0FC", "#F3F0FF", "#EDF2FF", "#E7F5FF", "#E3FAFC", "#E6FCF5", "#EBFBEE", "#F4FCE3", "#FFF9DB", "#FFF4E6" </s> add // Shade 9 </s> remove "#324E6B", "#9B5B1D", "#903839", "#4C7572", "#396733", "#AD9336", "#805976", "#BA737A", "#725646", "#88817D", "#000000" </s> add "#000000", "#343A40", "#495057", "#C92A2A", "#A61E4D", "#862E9C", "#5F3DC4", "#364FC7", "#1864AB", "#0B7285", "#087F5B", "#2B8A3E", "#5C940D", "#E67700", "#D9480F" </s> add // https://yeun.github.io/open-color/ </s> add // Shade 0
https://github.com/excalidraw/excalidraw/commit/cb8d866c33eceb82c8d85d1bbe55da463f32b592
src/components/ColorPicker.tsx
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep keep keep keep keep
<mask> "#F2F0EF", <mask> "#FFFFFF" <mask> ], <mask> elementBackground: [ <mask> "#4E79A7", <mask> "#F28E2C", <mask> "#E15759", <mask> "#76B7B2", <mask> "#59A14F", <mask> "#EDC949", <mask> "#AF7AA1", <mask> "#FF9DA7", <mask> "#9C755F", <mask> "#BAB0AB", <mask> "transparent" <mask> ], <mask> elementStroke: [ <mask> "#324E6B", <mask> "#9B5B1D", <mask> "#903839", </s> Open colors (#378) * Add open colors * More colors * Update colors * Shade 0 </s> remove "#324E6B", "#9B5B1D", "#903839", "#4C7572", "#396733", "#AD9336", "#805976", "#BA737A", "#725646", "#88817D", "#000000" </s> add "#000000", "#343A40", "#495057", "#C92A2A", "#A61E4D", "#862E9C", "#5F3DC4", "#364FC7", "#1864AB", "#0B7285", "#087F5B", "#2B8A3E", "#5C940D", "#E67700", "#D9480F" </s> remove "#DEE6EF", "#FCEAD8", "#F9E0E0", "#E6F1F1", "#E0EDDF", "#FBF5DD", "#F0E6ED", "#FFEDEF", "#EDE5E1", "#F2F0EF", "#FFFFFF" </s> add "#FFFFFF", "#F8F9FA", "#F1F3F5", "#FFF5F5", "#FFF0F6", "#F8F0FC", "#F3F0FF", "#EDF2FF", "#E7F5FF", "#E3FAFC", "#E6FCF5", "#EBFBEE", "#F4FCE3", "#FFF9DB", "#FFF4E6" </s> add // Shade 9 </s> add // Shade 6 </s> add // https://yeun.github.io/open-color/ </s> add // Shade 0
https://github.com/excalidraw/excalidraw/commit/cb8d866c33eceb82c8d85d1bbe55da463f32b592
src/components/ColorPicker.tsx
keep add keep keep keep keep keep keep
<mask> "#FD7E14" <mask> ], <mask> elementStroke: [ <mask> "#000000", <mask> "#343A40", <mask> "#495057", <mask> "#C92A2A", <mask> "#A61E4D", </s> Open colors (#378) * Add open colors * More colors * Update colors * Shade 0 </s> remove "#324E6B", "#9B5B1D", "#903839", "#4C7572", "#396733", "#AD9336", "#805976", "#BA737A", "#725646", "#88817D", "#000000" </s> add "#000000", "#343A40", "#495057", "#C92A2A", "#A61E4D", "#862E9C", "#5F3DC4", "#364FC7", "#1864AB", "#0B7285", "#087F5B", "#2B8A3E", "#5C940D", "#E67700", "#D9480F" </s> remove "#4E79A7", "#F28E2C", "#E15759", "#76B7B2", "#59A14F", "#EDC949", "#AF7AA1", "#FF9DA7", "#9C755F", "#BAB0AB", "transparent" </s> add "transparent", "#CED4DA", "#868E96", "#FA5252", "#E64980", "#BE4BDB", "#7950F2", "#4C6EF5", "#228BE6", "#15AABF", "#12B886", "#40C057", "#82C91E", "#FAB005", "#FD7E14" </s> add // Shade 6 </s> remove "#DEE6EF", "#FCEAD8", "#F9E0E0", "#E6F1F1", "#E0EDDF", "#FBF5DD", "#F0E6ED", "#FFEDEF", "#EDE5E1", "#F2F0EF", "#FFFFFF" </s> add "#FFFFFF", "#F8F9FA", "#F1F3F5", "#FFF5F5", "#FFF0F6", "#F8F0FC", "#F3F0FF", "#EDF2FF", "#E7F5FF", "#E3FAFC", "#E6FCF5", "#EBFBEE", "#F4FCE3", "#FFF9DB", "#FFF4E6" </s> add // https://yeun.github.io/open-color/ </s> add // Shade 0
https://github.com/excalidraw/excalidraw/commit/cb8d866c33eceb82c8d85d1bbe55da463f32b592
src/components/ColorPicker.tsx
keep keep keep keep replace replace replace replace replace replace replace replace replace replace replace keep keep
<mask> "#BAB0AB", <mask> "transparent" <mask> ], <mask> elementStroke: [ <mask> "#324E6B", <mask> "#9B5B1D", <mask> "#903839", <mask> "#4C7572", <mask> "#396733", <mask> "#AD9336", <mask> "#805976", <mask> "#BA737A", <mask> "#725646", <mask> "#88817D", <mask> "#000000" <mask> ] <mask> }; </s> Open colors (#378) * Add open colors * More colors * Update colors * Shade 0 </s> remove "#4E79A7", "#F28E2C", "#E15759", "#76B7B2", "#59A14F", "#EDC949", "#AF7AA1", "#FF9DA7", "#9C755F", "#BAB0AB", "transparent" </s> add "transparent", "#CED4DA", "#868E96", "#FA5252", "#E64980", "#BE4BDB", "#7950F2", "#4C6EF5", "#228BE6", "#15AABF", "#12B886", "#40C057", "#82C91E", "#FAB005", "#FD7E14" </s> add // Shade 9 </s> add // Shade 6 </s> remove "#DEE6EF", "#FCEAD8", "#F9E0E0", "#E6F1F1", "#E0EDDF", "#FBF5DD", "#F0E6ED", "#FFEDEF", "#EDE5E1", "#F2F0EF", "#FFFFFF" </s> add "#FFFFFF", "#F8F9FA", "#F1F3F5", "#FFF5F5", "#FFF0F6", "#F8F0FC", "#F3F0FF", "#EDF2FF", "#E7F5FF", "#E3FAFC", "#E6FCF5", "#EBFBEE", "#F4FCE3", "#FFF9DB", "#FFF4E6" </s> add // https://yeun.github.io/open-color/ </s> add // Shade 0
https://github.com/excalidraw/excalidraw/commit/cb8d866c33eceb82c8d85d1bbe55da463f32b592
src/components/ColorPicker.tsx
keep keep replace keep keep keep keep keep
<mask> import "./ToolIcon.scss"; <mask> <mask> import React from "react"; <mask> <mask> type ToolIconSize = "s" | "m"; <mask> <mask> type ToolButtonBaseProps = { <mask> icon?: React.ReactNode; </s> Fix keyboard shortcut (#587) * Fix keyboard shortcut Co-authored-by: David Luzar <[email protected]> </s> remove const innerRef = React.useRef(null); </s> add const innerRef = React.useRef<HTMLInputElement | HTMLButtonElement | null>( null, ); </s> add const prevChecked = React.useRef<boolean>( "checked" in props && props.checked, ); useEffect(() => { if (props.type !== "button") { if (props.checked && !prevChecked.current && innerRef.current) { innerRef.current.focus(); } prevChecked.current = props.checked; } }); </s> remove ref={innerRef} </s> add ref={node => (innerRef.current = node)} </s> remove ref={innerRef} </s> add ref={node => (innerRef.current = node)}
https://github.com/excalidraw/excalidraw/commit/cc3d71f13c0604406eda838344d99866dd94df39
src/components/ToolButton.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> export const ToolButton = React.forwardRef(function( <mask> props: ToolButtonProps, <mask> ref, <mask> ) { <mask> const innerRef = React.useRef(null); <mask> React.useImperativeHandle(ref, () => innerRef.current); <mask> const sizeCn = `ToolIcon_size_${props.size || DEFAULT_SIZE}`; <mask> <mask> if (props.type === "button") <mask> return ( </s> Fix keyboard shortcut (#587) * Fix keyboard shortcut Co-authored-by: David Luzar <[email protected]> </s> add const prevChecked = React.useRef<boolean>( "checked" in props && props.checked, ); useEffect(() => { if (props.type !== "button") { if (props.checked && !prevChecked.current && innerRef.current) { innerRef.current.focus(); } prevChecked.current = props.checked; } }); </s> remove import React from "react"; </s> add import React, { useEffect } from "react"; </s> remove ref={innerRef} </s> add ref={node => (innerRef.current = node)} </s> remove ref={innerRef} </s> add ref={node => (innerRef.current = node)}
https://github.com/excalidraw/excalidraw/commit/cc3d71f13c0604406eda838344d99866dd94df39
src/components/ToolButton.tsx
keep keep add keep keep keep keep
<mask> React.useImperativeHandle(ref, () => innerRef.current); <mask> const sizeCn = `ToolIcon_size_${props.size || DEFAULT_SIZE}`; <mask> <mask> if (props.type === "button") <mask> return ( <mask> <button <mask> className={`ToolIcon_type_button ToolIcon ${sizeCn}`} </s> Fix keyboard shortcut (#587) * Fix keyboard shortcut Co-authored-by: David Luzar <[email protected]> </s> remove const innerRef = React.useRef(null); </s> add const innerRef = React.useRef<HTMLInputElement | HTMLButtonElement | null>( null, ); </s> remove ref={innerRef} </s> add ref={node => (innerRef.current = node)} </s> remove ref={innerRef} </s> add ref={node => (innerRef.current = node)} </s> remove import React from "react"; </s> add import React, { useEffect } from "react";
https://github.com/excalidraw/excalidraw/commit/cc3d71f13c0604406eda838344d99866dd94df39
src/components/ToolButton.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> title={props.title} <mask> aria-label={props["aria-label"]} <mask> type="button" <mask> onClick={props.onClick} <mask> ref={innerRef} <mask> > <mask> <div className="ToolIcon__icon" aria-hidden="true"> <mask> {props.icon || props.label} <mask> </div> <mask> </button> </s> Fix keyboard shortcut (#587) * Fix keyboard shortcut Co-authored-by: David Luzar <[email protected]> </s> remove ref={innerRef} </s> add ref={node => (innerRef.current = node)} </s> remove const innerRef = React.useRef(null); </s> add const innerRef = React.useRef<HTMLInputElement | HTMLButtonElement | null>( null, ); </s> add const prevChecked = React.useRef<boolean>( "checked" in props && props.checked, ); useEffect(() => { if (props.type !== "button") { if (props.checked && !prevChecked.current && innerRef.current) { innerRef.current.focus(); } prevChecked.current = props.checked; } }); </s> remove import React from "react"; </s> add import React, { useEffect } from "react";
https://github.com/excalidraw/excalidraw/commit/cc3d71f13c0604406eda838344d99866dd94df39
src/components/ToolButton.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> aria-keyshortcuts={props["aria-keyshortcuts"]} <mask> id={props.id} <mask> onChange={props.onChange} <mask> checked={props.checked} <mask> ref={innerRef} <mask> /> <mask> <div className="ToolIcon__icon">{props.icon}</div> <mask> </label> <mask> ); <mask> }); </s> Fix keyboard shortcut (#587) * Fix keyboard shortcut Co-authored-by: David Luzar <[email protected]> </s> remove ref={innerRef} </s> add ref={node => (innerRef.current = node)} </s> add const prevChecked = React.useRef<boolean>( "checked" in props && props.checked, ); useEffect(() => { if (props.type !== "button") { if (props.checked && !prevChecked.current && innerRef.current) { innerRef.current.focus(); } prevChecked.current = props.checked; } }); </s> remove const innerRef = React.useRef(null); </s> add const innerRef = React.useRef<HTMLInputElement | HTMLButtonElement | null>( null, ); </s> remove import React from "react"; </s> add import React, { useEffect } from "react";
https://github.com/excalidraw/excalidraw/commit/cc3d71f13c0604406eda838344d99866dd94df39
src/components/ToolButton.tsx
keep keep add keep keep keep keep keep keep
<mask> INITAL_SCENE_UPDATE_TIMEOUT, <mask> TAP_TWICE_TIMEOUT, <mask> SYNC_FULL_SCENE_INTERVAL_MS, <mask> } from "../time_constants"; <mask> <mask> import LayerUI from "./LayerUI"; <mask> import { ScrollBars, SceneState } from "../scene/types"; <mask> import { generateCollaborationLink, getCollaborationLinkData } from "../data"; <mask> import { mutateElement, newElementWith } from "../element/mutateElement"; </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> remove event, </s> add { clientX, clientY }, </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => { </s> add clearTimeout(touchTimeout); </s> remove top: event.clientY, left: event.clientX, </s> add top: clientY, left: clientX, </s> add // remove touch handler for context menu on touch devices if (event.pointerType === "touch" && touchTimeout) { clearTimeout(touchTimeout); touchMoving = false; } </s> add // set touch moving for mobile context menu private handleTouchMove = (event: React.TouchEvent<HTMLCanvasElement>) => { touchMoving = true; };
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep add keep keep keep keep keep keep
<mask> let isPanning: boolean = false; <mask> let isDraggingScrollBar: boolean = false; <mask> let currentScrollBars: ScrollBars = { horizontal: null, vertical: null }; <mask> <mask> let lastPointerUp: ((event: any) => void) | null = null; <mask> const gesture: Gesture = { <mask> pointers: new Map(), <mask> lastCenter: null, <mask> initialDistance: null, </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> add // remove touch handler for context menu on touch devices if (event.pointerType === "touch" && touchTimeout) { clearTimeout(touchTimeout); touchMoving = false; } </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => { </s> remove event, </s> add { clientX, clientY }, </s> add clearTimeout(touchTimeout); </s> add // set touch moving for mobile context menu private handleTouchMove = (event: React.TouchEvent<HTMLCanvasElement>) => { touchMoving = true; }; </s> add this.openContextMenu(event); };
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep add keep keep keep keep keep keep
<mask> onPointerMove={this.handleCanvasPointerMove} <mask> onPointerUp={this.removePointer} <mask> onPointerCancel={this.removePointer} <mask> onDrop={this.handleCanvasOnDrop} <mask> > <mask> {t("labels.drawingCanvas")} <mask> </canvas> <mask> </main> <mask> </div> </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> remove top: event.clientY, left: event.clientX, </s> add top: clientY, left: clientX, </s> remove top: event.clientY, left: event.clientX, </s> add top: clientY, left: clientX, </s> remove event, </s> add { clientX, clientY }, </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => { </s> add this.openContextMenu(event); }; </s> add // deal with opening context menu on touch devices if (event.pointerType === "touch") { touchMoving = false; // open the context menu with the first touch's clientX and clientY // if the touch is not moving touchTimeout = window.setTimeout(() => { if (!touchMoving) { this.openContextMenu({ clientX: event.clientX, clientY: event.clientY, }); } }, TOUCH_CTX_MENU_TIMEOUT); }
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep add keep keep keep keep
<mask> this.unmounted = true; <mask> this.removeSceneCallback!(); <mask> this.removeEventListeners(); <mask> } <mask> <mask> private onResize = withBatchedUpdates(() => { <mask> globalSceneState </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> add // set touch moving for mobile context menu private handleTouchMove = (event: React.TouchEvent<HTMLCanvasElement>) => { touchMoving = true; }; </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => { </s> add // remove touch handler for context menu on touch devices if (event.pointerType === "touch" && touchTimeout) { clearTimeout(touchTimeout); touchMoving = false; } </s> remove event, </s> add { clientX, clientY }, </s> add this.openContextMenu(event); }; </s> add let touchTimeout = 0; let touchMoving = false;
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep keep add keep keep keep keep keep keep
<mask> this.setState(obj); <mask> }; <mask> <mask> removePointer = (event: React.PointerEvent<HTMLElement>) => { <mask> gesture.pointers.delete(event.pointerId); <mask> }; <mask> <mask> openPortal = async () => { <mask> window.history.pushState( <mask> {}, </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> add // set touch moving for mobile context menu private handleTouchMove = (event: React.TouchEvent<HTMLCanvasElement>) => { touchMoving = true; }; </s> add clearTimeout(touchTimeout); </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => { </s> add this.openContextMenu(event); }; </s> remove event, </s> add { clientX, clientY }, </s> add let touchTimeout = 0; let touchMoving = false;
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep add keep keep keep keep keep keep
<mask> } <mask> }; <mask> <mask> private handleCanvasPointerDown = ( <mask> event: React.PointerEvent<HTMLCanvasElement>, <mask> ) => { <mask> event.persist(); <mask> <mask> // deal with opening context menu on touch devices </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> add // deal with opening context menu on touch devices if (event.pointerType === "touch") { touchMoving = false; // open the context menu with the first touch's clientX and clientY // if the touch is not moving touchTimeout = window.setTimeout(() => { if (!touchMoving) { this.openContextMenu({ clientX: event.clientX, clientY: event.clientY, }); } }, TOUCH_CTX_MENU_TIMEOUT); } </s> add // remove touch handler for context menu on touch devices if (event.pointerType === "touch" && touchTimeout) { clearTimeout(touchTimeout); touchMoving = false; } </s> add this.openContextMenu(event); }; </s> remove event, </s> add { clientX, clientY }, </s> add clearTimeout(touchTimeout); </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => {
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep add keep keep keep keep keep
<mask> ) => { <mask> event.persist(); <mask> <mask> if (lastPointerUp !== null) { <mask> // Unfortunately, sometimes we don't get a pointerup after a pointerdown, <mask> // this can happen when a contextual menu or alert is triggered. In order to avoid <mask> // being in a weird state, we clean up on the next pointerdown <mask> lastPointerUp(event); </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> add // set touch moving for mobile context menu private handleTouchMove = (event: React.TouchEvent<HTMLCanvasElement>) => { touchMoving = true; }; </s> add // remove touch handler for context menu on touch devices if (event.pointerType === "touch" && touchTimeout) { clearTimeout(touchTimeout); touchMoving = false; } </s> remove event, </s> add { clientX, clientY }, </s> add this.openContextMenu(event); }; </s> remove top: event.clientY, left: event.clientX, </s> add top: clientY, left: clientX, </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => {
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep add keep keep keep keep keep
<mask> event: React.PointerEvent<HTMLCanvasElement>, <mask> ) => { <mask> event.preventDefault(); <mask> <mask> private openContextMenu = ({ <mask> clientX, <mask> clientY, <mask> }: { </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => { </s> add // set touch moving for mobile context menu private handleTouchMove = (event: React.TouchEvent<HTMLCanvasElement>) => { touchMoving = true; }; </s> remove event, </s> add { clientX, clientY }, </s> remove top: event.clientY, left: event.clientX, </s> add top: clientY, left: clientX, </s> add clearTimeout(touchTimeout); </s> add // remove touch handler for context menu on touch devices if (event.pointerType === "touch" && touchTimeout) { clearTimeout(touchTimeout); touchMoving = false; }
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep keep add keep keep keep keep
<mask> event.preventDefault(); <mask> this.openContextMenu(event); <mask> }; <mask> <mask> const { x, y } = viewportCoordsToSceneCoords( <mask> { clientX, clientY }, <mask> this.state, <mask> this.canvas, </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> remove event, </s> add { clientX, clientY }, </s> add this.openContextMenu(event); }; </s> add // deal with opening context menu on touch devices if (event.pointerType === "touch") { touchMoving = false; // open the context menu with the first touch's clientX and clientY // if the touch is not moving touchTimeout = window.setTimeout(() => { if (!touchMoving) { this.openContextMenu({ clientX: event.clientX, clientY: event.clientY, }); } }, TOUCH_CTX_MENU_TIMEOUT); } </s> remove top: event.clientY, left: event.clientX, </s> add top: clientY, left: clientX, </s> add let touchTimeout = 0; let touchMoving = false; </s> remove top: event.clientY, left: event.clientX, </s> add top: clientY, left: clientX,
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> ) => { <mask> event.preventDefault(); <mask> <mask> const { x, y } = viewportCoordsToSceneCoords( <mask> event, <mask> this.state, <mask> this.canvas, <mask> window.devicePixelRatio, <mask> ); <mask> </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => { </s> add this.openContextMenu(event); }; </s> add // set touch moving for mobile context menu private handleTouchMove = (event: React.TouchEvent<HTMLCanvasElement>) => { touchMoving = true; }; </s> add clearTimeout(touchTimeout); </s> add let touchTimeout = 0; let touchMoving = false; </s> add // remove touch handler for context menu on touch devices if (event.pointerType === "touch" && touchTimeout) { clearTimeout(touchTimeout); touchMoving = false; }
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> label: t("labels.toggleGridMode"), <mask> action: this.toggleGridMode, <mask> }, <mask> ], <mask> top: event.clientY, <mask> left: event.clientX, <mask> }); <mask> return; <mask> } <mask> <mask> if (!this.state.selectedElementIds[element.id]) { </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> remove top: event.clientY, left: event.clientX, </s> add top: clientY, left: clientX, </s> add // deal with opening context menu on touch devices if (event.pointerType === "touch") { touchMoving = false; // open the context menu with the first touch's clientX and clientY // if the touch is not moving touchTimeout = window.setTimeout(() => { if (!touchMoving) { this.openContextMenu({ clientX: event.clientX, clientY: event.clientY, }); } }, TOUCH_CTX_MENU_TIMEOUT); } </s> remove event, </s> add { clientX, clientY }, </s> add // remove touch handler for context menu on touch devices if (event.pointerType === "touch" && touchTimeout) { clearTimeout(touchTimeout); touchMoving = false; } </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => { </s> add TOUCH_CTX_MENU_TIMEOUT,
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> ...this.actionManager.getContextMenuItems( <mask> (action) => !CANVAS_ONLY_ACTIONS.includes(action.name), <mask> ), <mask> ], <mask> top: event.clientY, <mask> left: event.clientX, <mask> }); <mask> }; <mask> <mask> private handleWheel = withBatchedUpdates((event: WheelEvent) => { <mask> event.preventDefault(); </s> Add support for long press to context menu on iOS (#1769) * Initial support for touch context menu * Only deal with touch if it's available * Fix touch checking * Remove touch checking * Added comments * Combine onTouch with onPointer for mobile context menu support </s> remove top: event.clientY, left: event.clientX, </s> add top: clientY, left: clientX, </s> add this.openContextMenu(event); }; </s> add private openContextMenu = ({ clientX, clientY, }: { clientX: number; clientY: number; }) => { </s> add // deal with opening context menu on touch devices if (event.pointerType === "touch") { touchMoving = false; // open the context menu with the first touch's clientX and clientY // if the touch is not moving touchTimeout = window.setTimeout(() => { if (!touchMoving) { this.openContextMenu({ clientX: event.clientX, clientY: event.clientY, }); } }, TOUCH_CTX_MENU_TIMEOUT); } </s> remove event, </s> add { clientX, clientY }, </s> add clearTimeout(touchTimeout);
https://github.com/excalidraw/excalidraw/commit/cc52ea4ac295ef6cd60d86c2e7b21154466685a2
src/components/App.tsx
keep add keep keep keep keep
<mask> export const actionZoomIn = register({ <mask> name: "zoomIn", <mask> trackEvent: { category: "canvas" }, <mask> perform: (_elements, appState, _, app) => { <mask> return { <mask> appState: { </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionCanvas.tsx
keep add keep keep keep keep keep
<mask> export const actionZoomOut = register({ <mask> name: "zoomOut", <mask> trackEvent: { category: "canvas" }, <mask> perform: (_elements, appState, _, app) => { <mask> return { <mask> appState: { <mask> ...appState, </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionCanvas.tsx
keep keep add keep keep keep keep keep keep
<mask> <mask> export const actionResetZoom = register({ <mask> name: "resetZoom", <mask> trackEvent: { category: "canvas" }, <mask> perform: (_elements, appState, _, app) => { <mask> return { <mask> appState: { <mask> ...appState, <mask> ...getStateForZoom( </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionCanvas.tsx
keep keep keep add keep keep keep keep keep keep
<mask> }); <mask> <mask> export const actionZoomToFit = register({ <mask> name: "zoomToFit", <mask> trackEvent: { category: "canvas" }, <mask> perform: (elements, appState) => zoomToFitElements(elements, appState, false), <mask> keyTest: (event) => <mask> event.code === CODES.ONE && <mask> event.shiftKey && <mask> !event.altKey && </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionCanvas.tsx
keep keep add keep keep keep keep
<mask> <mask> export const actionToggleTheme = register({ <mask> name: "toggleTheme", <mask> trackEvent: { category: "canvas" }, <mask> perform: (_, appState, value) => { <mask> return { <mask> appState: { </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionCanvas.tsx
keep add keep keep keep keep keep keep
<mask> export const actionSaveFileToDisk = register({ <mask> name: "saveFileToDisk", <mask> trackEvent: { category: "export" }, <mask> perform: async (elements, appState, value, app) => { <mask> try { <mask> const { fileHandle } = await saveAsJSON( <mask> elements, <mask> { </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionExport.tsx
keep keep add keep keep keep keep keep
<mask> <mask> export const actionFullScreen = register({ <mask> name: "toggleFullScreen", <mask> trackEvent: { category: "canvas", predicate: (appState) => !isFullScreen() }, <mask> perform: () => { <mask> if (!isFullScreen()) { <mask> allowFullScreen(); <mask> } </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionMenu.tsx
keep add keep keep keep keep keep keep
<mask> export const actionShortcuts = register({ <mask> name: "toggleShortcuts", <mask> trackEvent: { category: "menu", action: "toggleHelpDialog" }, <mask> perform: (_elements, appState, _, { focusContainer }) => { <mask> if (appState.openDialog === "help") { <mask> focusContainer(); <mask> } <mask> return { </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionMenu.tsx
keep keep add keep keep keep keep keep keep
<mask> <mask> export const actionGoToCollaborator = register({ <mask> name: "goToCollaborator", <mask> trackEvent: { category: "collab" }, <mask> perform: (_elements, appState, value) => { <mask> const point = value as Collaborator["pointer"]; <mask> if (!point) { <mask> return { appState, commitToHistory: false }; <mask> } </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionNavigate.tsx
keep add keep keep keep keep
<mask> export const actionToggleGridMode = register({ <mask> name: "gridMode", <mask> trackEvent: { <mask> category: "canvas", <mask> predicate: (appState) => !appState.gridSize, <mask> }, </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionToggleGridMode.tsx
keep keep add keep keep keep keep keep
<mask> <mask> export const actionToggleStats = register({ <mask> name: "stats", <mask> trackEvent: { category: "menu" }, <mask> perform(elements, appState) { <mask> return { <mask> appState: { <mask> ...appState, </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionToggleStats.tsx
keep add keep keep keep keep keep keep
<mask> export const actionToggleViewMode = register({ <mask> name: "viewMode", <mask> trackEvent: { <mask> category: "canvas", <mask> predicate: (appState) => !appState.viewModeEnabled, <mask> }, <mask> perform(elements, appState) { <mask> return { </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionToggleViewMode.tsx
keep add keep keep keep keep keep keep
<mask> export const actionToggleZenMode = register({ <mask> name: "zenMode", <mask> trackEvent: { <mask> category: "canvas", <mask> predicate: (appState) => !appState.zenModeEnabled, <mask> }, <mask> perform(elements, appState) { <mask> return { </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/actionToggleZenMode.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> ActionSource, <mask> } from "./types"; <mask> import { ExcalidrawElement } from "../element/types"; <mask> import { AppClassProperties, AppState } from "../types"; <mask> import { MODES } from "../constants"; <mask> import { trackEvent } from "../analytics"; <mask> <mask> const trackAction = ( <mask> action: Action, <mask> source: ActionSource, </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> remove export const MODES = { VIEW: "viewMode", ZEN: "zenMode", GRID: "gridMode", }; </s> add </s> remove const { viewModeEnabled } = this.getAppState(); if (viewModeEnabled) { if (!Object.values(MODES).includes(data[0].name)) { return false; } </s> add if (this.getAppState().viewModeEnabled && action.viewMode !== true) { return false; </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/manager.tsx
keep keep keep keep replace replace replace replace replace keep keep keep keep keep
<mask> } <mask> <mask> const action = data[0]; <mask> <mask> const { viewModeEnabled } = this.getAppState(); <mask> if (viewModeEnabled) { <mask> if (!Object.values(MODES).includes(data[0].name)) { <mask> return false; <mask> } <mask> } <mask> <mask> const elements = this.getElementsIncludingDeleted(); <mask> const appState = this.getAppState(); <mask> const value = null; </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> remove export const MODES = { VIEW: "viewMode", ZEN: "zenMode", GRID: "gridMode", }; </s> add </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/manager.tsx
keep keep keep add keep
<mask> elements: readonly ExcalidrawElement[], <mask> value: any, <mask> ) => boolean; <mask> }; <mask> } </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> remove export const MODES = { VIEW: "viewMode", ZEN: "zenMode", GRID: "gridMode", }; </s> add </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true,
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/actions/types.ts
keep keep keep keep replace replace replace replace replace replace keep keep keep keep keep
<mask> export const IDLE_THRESHOLD = 60_000; <mask> // Report a user active each ACTIVE_THRESHOLD milliseconds <mask> export const ACTIVE_THRESHOLD = 3_000; <mask> <mask> export const MODES = { <mask> VIEW: "viewMode", <mask> ZEN: "zenMode", <mask> GRID: "gridMode", <mask> }; <mask> <mask> export const THEME_FILTER = cssVariables.themeFilter; <mask> <mask> export const URL_QUERY_KEYS = { <mask> addLibrary: "addLibrary", <mask> } as const; </s> feat: allow readonly actions to be used in viewMode (#5982) </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> add viewMode: true, </s> remove const { viewModeEnabled } = this.getAppState(); if (viewModeEnabled) { if (!Object.values(MODES).includes(data[0].name)) { return false; } </s> add if (this.getAppState().viewModeEnabled && action.viewMode !== true) { return false;
https://github.com/excalidraw/excalidraw/commit/cc9e76458502e5e246b221f56d8fb2847c2fdc45
src/constants.ts
keep keep keep replace replace keep keep keep keep keep
<mask> // This optional code is used to register a service worker. <mask> // register() is not called by default. <mask> <mask> import { push } from "./components/Toast"; <mask> <mask> // This lets the app load faster on subsequent visits in production, and gives <mask> // it offline capabilities. However, it also means that developers (and users) <mask> // will only see deployed updates on subsequent visits to a page, after all the <mask> // existing tabs open on the page have been closed, since previously cached <mask> // resources are updated in the background. </s> Disable notifications (#1421) * Remove notifications * remove dead component </s> remove push("Content is cached for offline use."); </s> add // console.log("Content is cached for offline use."); </s> remove push( "New content is available and will be used when all " + "tabs for this page are closed.", ); </s> add // console.log( // "New content is available and will be used when all " + // "tabs for this page are closed.", // ); </s> remove push("No internet connection found. App is running in offline mode."); </s> add // console.log( // "No internet connection found. App is running in offline mode.", // );
https://github.com/excalidraw/excalidraw/commit/cca15b06407cce2ba9d3fae1d0c77f22f723f603
src/serviceWorker.tsx
keep keep keep keep replace replace replace replace keep keep keep keep keep
<mask> if (navigator.serviceWorker.controller) { <mask> // At this point, the updated precached content has been fetched, <mask> // but the previous service worker will still serve the older <mask> // content until all client tabs are closed. <mask> push( <mask> "New content is available and will be used when all " + <mask> "tabs for this page are closed.", <mask> ); <mask> <mask> // Execute callback <mask> if (config && config.onUpdate) { <mask> config.onUpdate(registration); <mask> } </s> Disable notifications (#1421) * Remove notifications * remove dead component </s> remove push("Content is cached for offline use."); </s> add // console.log("Content is cached for offline use."); </s> remove import { push } from "./components/Toast"; </s> add </s> remove push("No internet connection found. App is running in offline mode."); </s> add // console.log( // "No internet connection found. App is running in offline mode.", // );
https://github.com/excalidraw/excalidraw/commit/cca15b06407cce2ba9d3fae1d0c77f22f723f603
src/serviceWorker.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> } else { <mask> // At this point, everything has been precached. <mask> // It's the perfect time to display a <mask> // "Content is cached for offline use." message. <mask> push("Content is cached for offline use."); <mask> <mask> // Execute callback <mask> if (config && config.onSuccess) { <mask> config.onSuccess(registration); <mask> } </s> Disable notifications (#1421) * Remove notifications * remove dead component </s> remove push("No internet connection found. App is running in offline mode."); </s> add // console.log( // "No internet connection found. App is running in offline mode.", // ); </s> remove push( "New content is available and will be used when all " + "tabs for this page are closed.", ); </s> add // console.log( // "New content is available and will be used when all " + // "tabs for this page are closed.", // ); </s> remove import { push } from "./components/Toast"; </s> add
https://github.com/excalidraw/excalidraw/commit/cca15b06407cce2ba9d3fae1d0c77f22f723f603
src/serviceWorker.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> registerValidSW(swUrl, config); <mask> } <mask> }) <mask> .catch(() => { <mask> push("No internet connection found. App is running in offline mode."); <mask> }); <mask> } <mask> <mask> export function unregister() { <mask> if ("serviceWorker" in navigator) { </s> Disable notifications (#1421) * Remove notifications * remove dead component </s> remove push("Content is cached for offline use."); </s> add // console.log("Content is cached for offline use."); </s> remove push( "New content is available and will be used when all " + "tabs for this page are closed.", ); </s> add // console.log( // "New content is available and will be used when all " + // "tabs for this page are closed.", // ); </s> remove import { push } from "./components/Toast"; </s> add
https://github.com/excalidraw/excalidraw/commit/cca15b06407cce2ba9d3fae1d0c77f22f723f603
src/serviceWorker.tsx
keep keep add keep keep
<mask> "repository": { <mask> "type": "git", <mask> "url": "https://github.com/excalidraw/excalidraw.git" <mask> } <mask> } </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove import { FlooredNumber } from "../types"; </s> add import { FlooredNumber, AppState } from "../types"; </s> remove import { hasBackground, hasStroke, hasText, clearSelection } from "../scene"; </s> add import { hasBackground, hasStroke, hasText } from "../scene"; </s> remove import { clearSelection } from "../scene"; </s> add </s> remove import { Drawable } from "roughjs/bin/core"; </s> add </s> add import { AppState } from "../types"; import { getShapeForElement } from "../renderer/renderElement"; </s> remove }); </s> add selectedElementIds: { ...prevState.selectedElementIds, [this.state.draggingElement!.id]: true, }, }));
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
package.json
keep keep keep keep replace keep keep keep keep keep
<mask> export const actionDeleteSelected = register({ <mask> name: "deleteSelectedElements", <mask> perform: (elements, appState) => { <mask> return { <mask> elements: deleteSelectedElements(elements), <mask> appState: { ...appState, elementType: "selection", multiElement: null }, <mask> }; <mask> }, <mask> contextItemLabel: "labels.delete", <mask> contextMenuOrder: 3, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: moveOneRight([...elements], getSelectedIndices(elements)), </s> add elements: moveOneRight( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveOneLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveOneLeft( [...elements], getSelectedIndices(elements, appState), ), </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove elements: moveAllRight([...elements], getSelectedIndices(elements)), </s> add elements: moveAllRight( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveAllLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveAllLeft( [...elements], getSelectedIndices(elements, appState), ), </s> remove perform: elements => { </s> add perform: (elements, appState) => {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionDeleteSelected.tsx
keep keep keep replace keep replace keep keep keep
<mask> }, <mask> contextItemLabel: "labels.delete", <mask> contextMenuOrder: 3, <mask> commitToHistory: (_, elements) => isSomeElementSelected(elements), <mask> keyTest: event => event.key === KEYS.BACKSPACE || event.key === KEYS.DELETE, <mask> PanelComponent: ({ elements, updateData }) => ( <mask> <ToolButton <mask> type="button" <mask> icon={trash} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: elements.map(elem => ({ ...elem, isSelected: true })), </s> add appState: { ...appState, selectedElementIds: Object.fromEntries( elements.map(element => [element.id, true]), ), }, </s> remove elements: deleteSelectedElements(elements), </s> add elements: deleteSelectedElements(elements, appState), </s> add selectedElementIds: {}, </s> remove const selectedElements = getSelectedElements(elements); </s> add const selectedElements = getSelectedElements(elements, appState); </s> remove elements: elements.map(({ shape, canvas, ...element }) => ({ </s> add elements: elements.map(element => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionDeleteSelected.tsx
keep keep keep keep replace keep keep keep
<mask> icon={trash} <mask> title={t("labels.delete")} <mask> aria-label={t("labels.delete")} <mask> onClick={() => updateData(null)} <mask> visible={isSomeElementSelected(elements)} <mask> /> <mask> ), <mask> }); </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove PanelComponent: ({ elements, updateData }) => ( </s> add PanelComponent: ({ elements, appState, updateData }) => ( </s> remove <HintViewer elementType={appState.elementType} multiMode={appState.multiElement !== null} isResizing={appState.isResizing} elements={elements} /> </s> add <HintViewer appState={appState} elements={elements} /> </s> remove <HintViewer elementType={appState.elementType} multiMode={appState.multiElement !== null} isResizing={appState.isResizing} elements={elements} /> </s> add <HintViewer appState={appState} elements={elements} /> </s> remove this.setState({}); </s> add this.setState({ selectedElementIds: Object.fromEntries( newElements.map(element => [element.id, true]), ), }); </s> add appState, </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionDeleteSelected.tsx
keep replace keep keep keep keep keep
<mask> import { KEYS } from "../keys"; <mask> import { clearSelection } from "../scene"; <mask> import { isInvisiblySmallElement } from "../element"; <mask> import { resetCursor } from "../utils"; <mask> import React from "react"; <mask> import { ToolButton } from "../components/ToolButton"; <mask> import { done } from "../components/icons"; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove import { hasBackground, hasStroke, hasText, clearSelection } from "../scene"; </s> add import { hasBackground, hasStroke, hasText } from "../scene"; </s> remove import { FlooredNumber } from "../types"; </s> add import { FlooredNumber, AppState } from "../types"; </s> remove import { Drawable } from "roughjs/bin/core"; </s> add </s> add import { AppState } from "../types"; </s> add import { AppState } from "../types"; import { getShapeForElement } from "../renderer/renderElement"; </s> add import { AppState } from "../types";
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionFinalize.tsx
keep add keep keep keep keep
<mask> import { t } from "../i18n"; <mask> import { register } from "./register"; <mask> <mask> export const actionFinalize = register({ <mask> name: "finalize", <mask> perform: (elements, appState) => { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove import { hasBackground, hasStroke, hasText, clearSelection } from "../scene"; </s> add import { hasBackground, hasStroke, hasText } from "../scene"; </s> remove let newElements = clearSelection(elements); </s> add let newElements = elements; </s> remove import { FlooredNumber } from "../types"; </s> add import { FlooredNumber, AppState } from "../types"; </s> remove import { clearSelection } from "../scene"; </s> add </s> remove import { Drawable } from "roughjs/bin/core"; </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionFinalize.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> <mask> export const actionFinalize = register({ <mask> name: "finalize", <mask> perform: (elements, appState) => { <mask> let newElements = clearSelection(elements); <mask> if (window.document.activeElement instanceof HTMLElement) { <mask> window.document.activeElement.blur(); <mask> } <mask> if (appState.multiElement) { <mask> // pen and mouse have hover </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add import { invalidateShapeForElement } from "../renderer/renderElement"; </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove perform: elements => { const element = elements.find(el => el.isSelected); </s> add perform: (elements, appState) => { const element = elements.find(el => appState.selectedElementIds[el.id]); </s> remove perform: elements => { </s> add perform: (elements, appState) => { </s> remove elements: moveOneRight([...elements], getSelectedIndices(elements)), </s> add elements: moveOneRight( [...elements], getSelectedIndices(elements, appState), ), </s> remove elements: moveOneLeft([...elements], getSelectedIndices(elements)), </s> add elements: moveOneLeft( [...elements], getSelectedIndices(elements, appState), ),
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionFinalize.tsx
keep replace keep replace keep keep
<mask> } <mask> appState.multiElement.shape = null; <mask> if (!appState.elementLocked) { <mask> appState.multiElement.isSelected = true; <mask> } <mask> } </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove multiElement.shape = null; </s> add invalidateShapeForElement(multiElement); </s> remove element.shape = null; </s> add invalidateShapeForElement(element); </s> remove multiElement.isSelected = true; </s> add this.setState(prevState => ({ selectedElementIds: { ...prevState.selectedElementIds, [multiElement.id]: true, }, })); </s> remove draggingElement.shape = null; </s> add invalidateShapeForElement(draggingElement); </s> remove this.state.draggingElement!.isSelected = true; </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionFinalize.tsx
keep keep keep add keep keep keep keep keep keep
<mask> ? appState.elementType <mask> : "selection", <mask> draggingElement: null, <mask> multiElement: null, <mask> }, <mask> }; <mask> }, <mask> keyTest: (event, appState) => <mask> (event.key === KEYS.ESCAPE && <mask> !appState.draggingElement && </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove this.state.draggingElement!.isSelected = true; </s> add </s> remove }); </s> add selectedElementIds: { ...prevState.selectedElementIds, [this.state.draggingElement!.id]: true, }, })); </s> remove shape: null, canvas: null, canvasOffsetX: element.canvasOffsetX || 0, canvasOffsetY: element.canvasOffsetY || 0, </s> add </s> remove this.setState({ </s> add this.setState(prevState => ({ </s> remove shape: null, canvas: null, </s> add </s> remove this.setState({ </s> add this.setState(prevState => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionFinalize.tsx
keep add keep keep keep keep keep keep
<mask> const changeProperty = ( <mask> elements: readonly ExcalidrawElement[], <mask> callback: (element: ExcalidrawElement) => ExcalidrawElement, <mask> ) => { <mask> return elements.map(element => { <mask> if (appState.selectedElementIds[element.id]) { <mask> return callback(element); <mask> } </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove if (element.isSelected) { </s> add if (appState.selectedElementIds[element.id]) { </s> remove editingElement: AppState["editingElement"], </s> add </s> remove if (element.isSelected) { </s> add if (appState.selectedElementIds[element.id]) { </s> add appState: AppState, </s> remove if (element.isSelected) { </s> add if (appState.selectedElementIds[element.id]) { </s> remove export function getSelectedIndices(elements: readonly ExcalidrawElement[]) { </s> add export function getSelectedIndices( elements: readonly ExcalidrawElement[], appState: AppState, ) {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> elements: readonly ExcalidrawElement[], <mask> callback: (element: ExcalidrawElement) => ExcalidrawElement, <mask> ) => { <mask> return elements.map(element => { <mask> if (element.isSelected) { <mask> return callback(element); <mask> } <mask> return element; <mask> }); <mask> }; </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState: AppState, </s> remove if (element.isSelected) { </s> add if (appState.selectedElementIds[element.id]) { </s> remove editingElement: AppState["editingElement"], </s> add </s> remove export function getSelectedIndices(elements: readonly ExcalidrawElement[]) { </s> add export function getSelectedIndices( elements: readonly ExcalidrawElement[], appState: AppState, ) { </s> remove export function clearSelection(elements: readonly ExcalidrawElement[]) { let someWasSelected = false; elements.forEach(element => { if (element.isSelected) { someWasSelected = true; element.isSelected = false; } }); return someWasSelected ? elements.slice() : elements; } export function deleteSelectedElements(elements: readonly ExcalidrawElement[]) { return elements.filter(el => !el.isSelected); </s> add export function deleteSelectedElements( elements: readonly ExcalidrawElement[], appState: AppState, ) { return elements.filter(el => !appState.selectedElementIds[el.id]); </s> remove if (element.isSelected) { </s> add if (appState.selectedElementIds[element.id]) {
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> }); <mask> }; <mask> <mask> const getFormValue = function<T>( <mask> editingElement: AppState["editingElement"], <mask> elements: readonly ExcalidrawElement[], <mask> getAttribute: (element: ExcalidrawElement) => T, <mask> defaultValue?: T, <mask> ): T | null { <mask> return ( </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState: AppState, </s> add const editingElement = appState.editingElement; </s> add appState: AppState, </s> remove (isSomeElementSelected(elements) ? getCommonAttributeOfSelectedElements(elements, getAttribute) </s> add (isSomeElementSelected(elements, appState) ? getCommonAttributeOfSelectedElements(elements, appState, getAttribute) </s> remove getSelectedElements(elements).map(element => getAttribute(element)), </s> add getSelectedElements(elements, appState).map(element => getAttribute(element), ), </s> add appState: AppState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep add keep keep keep keep keep keep
<mask> <mask> const getFormValue = function<T>( <mask> elements: readonly ExcalidrawElement[], <mask> getAttribute: (element: ExcalidrawElement) => T, <mask> defaultValue?: T, <mask> ): T | null { <mask> const editingElement = appState.editingElement; <mask> return ( <mask> (editingElement && getAttribute(editingElement)) ?? </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add const editingElement = appState.editingElement; </s> remove editingElement: AppState["editingElement"], </s> add </s> remove (isSomeElementSelected(elements) ? getCommonAttributeOfSelectedElements(elements, getAttribute) </s> add (isSomeElementSelected(elements, appState) ? getCommonAttributeOfSelectedElements(elements, appState, getAttribute) </s> add appState: AppState, </s> remove getSelectedElements(elements).map(element => getAttribute(element)), </s> add getSelectedElements(elements, appState).map(element => getAttribute(element), ), </s> add appState: AppState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep add keep keep keep keep keep
<mask> getAttribute: (element: ExcalidrawElement) => T, <mask> defaultValue?: T, <mask> ): T | null { <mask> return ( <mask> (editingElement && getAttribute(editingElement)) ?? <mask> (isSomeElementSelected(elements, appState) <mask> ? getCommonAttributeOfSelectedElements(elements, appState, getAttribute) <mask> : defaultValue) ?? </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove (isSomeElementSelected(elements) ? getCommonAttributeOfSelectedElements(elements, getAttribute) </s> add (isSomeElementSelected(elements, appState) ? getCommonAttributeOfSelectedElements(elements, appState, getAttribute) </s> add appState: AppState, </s> remove editingElement: AppState["editingElement"], </s> add </s> remove getSelectedElements(elements).map(element => getAttribute(element)), </s> add getSelectedElements(elements, appState).map(element => getAttribute(element), ), </s> add appState: AppState, </s> add appState: AppState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace replace keep keep keep keep keep
<mask> defaultValue?: T, <mask> ): T | null { <mask> return ( <mask> (editingElement && getAttribute(editingElement)) ?? <mask> (isSomeElementSelected(elements) <mask> ? getCommonAttributeOfSelectedElements(elements, getAttribute) <mask> : defaultValue) ?? <mask> null <mask> ); <mask> }; <mask> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add const editingElement = appState.editingElement; </s> add appState: AppState, </s> remove editingElement: AppState["editingElement"], </s> add </s> remove getSelectedElements(elements).map(element => getAttribute(element)), </s> add getSelectedElements(elements, appState).map(element => getAttribute(element), ), </s> add appState: AppState, </s> remove shape: null, canvas: null, canvasOffsetX: element.canvasOffsetX || 0, canvasOffsetY: element.canvasOffsetY || 0, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep replace keep keep
<mask> export const actionChangeStrokeColor = register({ <mask> name: "changeStrokeColor", <mask> perform: (elements, appState, value) => { <mask> return { <mask> elements: changeProperty(elements, el => ({ <mask> ...el, <mask> shape: null, <mask> strokeColor: value, <mask> })), </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> <ColorPicker <mask> type="elementStroke" <mask> label={t("labels.stroke")} <mask> color={getFormValue( <mask> appState.editingElement, <mask> elements, <mask> element => element.strokeColor, <mask> appState.currentItemStrokeColor, <mask> )} <mask> onChange={updateData} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState, </s> remove appState.editingElement, </s> add </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep add keep keep keep keep keep
<mask> type="elementStroke" <mask> label={t("labels.stroke")} <mask> color={getFormValue( <mask> elements, <mask> element => element.strokeColor, <mask> appState.currentItemStrokeColor, <mask> )} <mask> onChange={updateData} <mask> /> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove appState.editingElement, </s> add </s> add appState, </s> remove appState.editingElement, </s> add </s> add appState, </s> add appState, </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep replace keep keep
<mask> export const actionChangeBackgroundColor = register({ <mask> name: "changeBackgroundColor", <mask> perform: (elements, appState, value) => { <mask> return { <mask> elements: changeProperty(elements, el => ({ <mask> ...el, <mask> shape: null, <mask> backgroundColor: value, <mask> })), </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> <ColorPicker <mask> type="elementBackground" <mask> label={t("labels.background")} <mask> color={getFormValue( <mask> appState.editingElement, <mask> elements, <mask> element => element.backgroundColor, <mask> appState.currentItemBackgroundColor, <mask> )} <mask> onChange={updateData} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState, </s> remove appState.editingElement, </s> add </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep add keep keep keep keep keep
<mask> label={t("labels.background")} <mask> color={getFormValue( <mask> elements, <mask> element => element.backgroundColor, <mask> appState.currentItemBackgroundColor, <mask> )} <mask> onChange={updateData} <mask> /> </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove appState.editingElement, </s> add </s> add appState, </s> remove appState.editingElement, </s> add </s> add appState, </s> add appState, </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep replace keep
<mask> export const actionChangeFillStyle = register({ <mask> name: "changeFillStyle", <mask> perform: (elements, appState, value) => { <mask> return { <mask> elements: changeProperty(elements, el => ({ <mask> ...el, <mask> shape: null, <mask> fillStyle: value, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep keep keep keep keep
<mask> { value: "cross-hatch", text: t("labels.crossHatch") }, <mask> ]} <mask> group="fill" <mask> value={getFormValue( <mask> appState.editingElement, <mask> elements, <mask> element => element.fillStyle, <mask> appState.currentItemFillStyle, <mask> )} <mask> onChange={value => { </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep add keep keep keep keep keep keep
<mask> ]} <mask> group="fill" <mask> value={getFormValue( <mask> elements, <mask> element => element.fillStyle, <mask> appState.currentItemFillStyle, <mask> )} <mask> onChange={value => { <mask> updateData(value); <mask> }} </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove appState.editingElement, </s> add </s> add appState, </s> add appState, </s> remove appState.editingElement, </s> add </s> remove appState.editingElement, </s> add </s> add appState,
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx
keep keep keep keep replace keep replace keep keep keep
<mask> export const actionChangeStrokeWidth = register({ <mask> name: "changeStrokeWidth", <mask> perform: (elements, appState, value) => { <mask> return { <mask> elements: changeProperty(elements, el => ({ <mask> ...el, <mask> shape: null, <mask> strokeWidth: value, <mask> })), <mask> appState: { ...appState, currentItemStrokeWidth: value }, </s> Refactor ExcalidrawElement (#874) * Get rid of isSelected, canvas, canvasZoom, canvasOffsetX and canvasOffsetY on ExcalidrawElement. * Fix most unit tests. Fix cmd a. Fix alt drag * Focus on paste * shift select should include previously selected items * Fix last test * Move this.shape out of ExcalidrawElement and into a WeakMap </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({ </s> remove elements: changeProperty(elements, el => ({ </s> add elements: changeProperty(elements, appState, el => ({
https://github.com/excalidraw/excalidraw/commit/ccbbdb75a6fdf057d913a97caa9692923761c8ca
src/actions/actionProperties.tsx