fix: on contextMenu, use selected element regardless of z-index (#3668)

This commit is contained in:
David Luzar 2021-05-29 22:33:53 +02:00 committed by GitHub
parent 60cea7a0c2
commit c819b653bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 216 additions and 1 deletions

View file

@ -20,6 +20,15 @@ const readFile = util.promisify(fs.readFile);
const { h } = window;
export class API {
static setSelectedElements = (elements: ExcalidrawElement[]) => {
h.setState({
selectedElementIds: elements.reduce((acc, element) => {
acc[element.id] = true;
return acc;
}, {} as Record<ExcalidrawElement["id"], true>),
});
};
static getSelectedElements = (): ExcalidrawElement[] => {
return h.elements.filter(
(element) => h.state.selectedElementIds[element.id],