3aa01ad272
* chore: Remove tracking * process * rename * remove * prod * Update public/index.html Co-authored-by: David Luzar <luzar.david@gmail.com> * Update public/index.html * eol * more * stats Co-authored-by: David Luzar <luzar.david@gmail.com>
23 lines
682 B
TypeScript
23 lines
682 B
TypeScript
import { register } from "./register";
|
|
import { getSelectedElements } from "../scene";
|
|
import { getNonDeletedElements } from "../element";
|
|
import { deepCopyElement } from "../element/newElement";
|
|
import { Library } from "../data/library";
|
|
|
|
export const actionAddToLibrary = register({
|
|
name: "addToLibrary",
|
|
perform: (elements, appState) => {
|
|
const selectedElements = getSelectedElements(
|
|
getNonDeletedElements(elements),
|
|
appState,
|
|
);
|
|
|
|
Library.loadLibrary().then((items) => {
|
|
Library.saveLibrary([...items, selectedElements.map(deepCopyElement)]);
|
|
});
|
|
return false;
|
|
},
|
|
contextMenuOrder: 6,
|
|
contextItemLabel: "labels.addToLibrary",
|
|
});
|