mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-04-14 16:40:58 -04:00
fix: adding to library via contextmenu when no image is selected (#4356)
This commit is contained in:
parent
1c7ee09010
commit
f354788cd0
1 changed files with 6 additions and 5 deletions
|
@ -8,7 +8,11 @@ import { t } from "../i18n";
|
||||||
export const actionAddToLibrary = register({
|
export const actionAddToLibrary = register({
|
||||||
name: "addToLibrary",
|
name: "addToLibrary",
|
||||||
perform: (elements, appState, _, app) => {
|
perform: (elements, appState, _, app) => {
|
||||||
if (elements.some((element) => element.type === "image")) {
|
const selectedElements = getSelectedElements(
|
||||||
|
getNonDeletedElements(elements),
|
||||||
|
appState,
|
||||||
|
);
|
||||||
|
if (selectedElements.some((element) => element.type === "image")) {
|
||||||
return {
|
return {
|
||||||
commitToHistory: false,
|
commitToHistory: false,
|
||||||
appState: {
|
appState: {
|
||||||
|
@ -25,10 +29,7 @@ export const actionAddToLibrary = register({
|
||||||
{
|
{
|
||||||
id: randomId(),
|
id: randomId(),
|
||||||
status: "unpublished",
|
status: "unpublished",
|
||||||
elements: getSelectedElements(
|
elements: selectedElements.map(deepCopyElement),
|
||||||
getNonDeletedElements(elements),
|
|
||||||
appState,
|
|
||||||
).map(deepCopyElement),
|
|
||||||
created: Date.now(),
|
created: Date.now(),
|
||||||
},
|
},
|
||||||
...items,
|
...items,
|
||||||
|
|
Loading…
Add table
Reference in a new issue