mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: support selecting multiple library items via shift
(#4306)
This commit is contained in:
parent
b53d1f6f3e
commit
06db702b5d
15 changed files with 117 additions and 67 deletions
13
src/utils.ts
13
src/utils.ts
|
@ -476,3 +476,16 @@ export const bytesToHexString = (bytes: Uint8Array) => {
|
|||
|
||||
export const getUpdatedTimestamp = () =>
|
||||
process.env.NODE_ENV === "test" ? 1 : Date.now();
|
||||
|
||||
/**
|
||||
* Transforms array of objects containing `id` attribute,
|
||||
* or array of ids (strings), into a Map, keyd by `id`.
|
||||
*/
|
||||
export const arrayToMap = <T extends { id: string } | string>(
|
||||
items: readonly T[],
|
||||
) => {
|
||||
return items.reduce((acc: Map<string, T>, element) => {
|
||||
acc.set(typeof element === "string" ? element : element.id, element);
|
||||
return acc;
|
||||
}, new Map());
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue