Library MVP (#1787)

Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
Pete Hunt 2020-07-10 02:20:23 -07:00 committed by GitHub
parent 7ab0c1aba8
commit 6428b59ccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 599 additions and 20 deletions

View file

@ -0,0 +1,23 @@
import { register } from "./register";
import { getSelectedElements } from "../scene";
import { getNonDeletedElements } from "../element";
import { deepCopyElement } from "../element/newElement";
import { loadLibrary, saveLibrary } from "../data/localStorage";
export const actionAddToLibrary = register({
name: "addToLibrary",
perform: (elements, appState) => {
const selectedElements = getSelectedElements(
getNonDeletedElements(elements),
appState,
);
loadLibrary().then((items) => {
saveLibrary([...items, selectedElements.map(deepCopyElement)]);
});
return false;
},
contextMenuOrder: 6,
contextItemLabel: "labels.addToLibrary",
});

View file

@ -49,3 +49,5 @@ export {
export { actionGroup, actionUngroup } from "./actionGroup";
export { actionGoToCollaborator } from "./actionNavigate";
export { actionAddToLibrary } from "./actionAddToLibrary";

View file

@ -62,7 +62,8 @@ export type ActionName =
| "toggleShortcuts"
| "group"
| "ungroup"
| "goToCollaborator";
| "goToCollaborator"
| "addToLibrary";
export interface Action {
name: ActionName;