|
|
|
@ -49,7 +49,7 @@ interface LayerUIProps {
|
|
|
|
|
actionManager: ActionManager;
|
|
|
|
|
appState: AppState;
|
|
|
|
|
canvas: HTMLCanvasElement | null;
|
|
|
|
|
setAppState: any;
|
|
|
|
|
setAppState: React.Component<any, AppState>["setState"];
|
|
|
|
|
elements: readonly NonDeletedExcalidrawElement[];
|
|
|
|
|
onRoomCreate: () => void;
|
|
|
|
|
onUsernameChange: (username: string) => void;
|
|
|
|
@ -103,7 +103,7 @@ const LibraryMenuItems = ({
|
|
|
|
|
onRemoveFromLibrary: (index: number) => void;
|
|
|
|
|
onInsertShape: (elements: LibraryItem) => void;
|
|
|
|
|
onAddToLibrary: (elements: LibraryItem) => void;
|
|
|
|
|
setAppState: any;
|
|
|
|
|
setAppState: React.Component<any, AppState>["setState"];
|
|
|
|
|
}) => {
|
|
|
|
|
const isMobile = useIsMobile();
|
|
|
|
|
const numCells = library.length + (pendingElements.length > 0 ? 1 : 0);
|
|
|
|
@ -202,7 +202,7 @@ const LibraryMenu = ({
|
|
|
|
|
onClickOutside: (event: MouseEvent) => void;
|
|
|
|
|
onInsertShape: (elements: LibraryItem) => void;
|
|
|
|
|
onAddToLibrary: () => void;
|
|
|
|
|
setAppState: any;
|
|
|
|
|
setAppState: React.Component<any, AppState>["setState"];
|
|
|
|
|
}) => {
|
|
|
|
|
const ref = useRef<HTMLDivElement | null>(null);
|
|
|
|
|
useOnClickOutside(ref, onClickOutside);
|
|
|
|
@ -309,18 +309,23 @@ const LayerUI = ({
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const renderExportDialog = () => {
|
|
|
|
|
const createExporter = (type: ExportType): ExportCB => (
|
|
|
|
|
const createExporter = (type: ExportType): ExportCB => async (
|
|
|
|
|
exportedElements,
|
|
|
|
|
scale,
|
|
|
|
|
) => {
|
|
|
|
|
if (canvas) {
|
|
|
|
|
exportCanvas(type, exportedElements, appState, canvas, {
|
|
|
|
|
try {
|
|
|
|
|
await exportCanvas(type, exportedElements, appState, canvas, {
|
|
|
|
|
exportBackground: appState.exportBackground,
|
|
|
|
|
name: appState.name,
|
|
|
|
|
viewBackgroundColor: appState.viewBackgroundColor,
|
|
|
|
|
scale,
|
|
|
|
|
shouldAddWatermark: appState.shouldAddWatermark,
|
|
|
|
|
});
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
setAppState({ errorMessage: error.message });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return (
|
|
|
|
@ -331,9 +336,10 @@ const LayerUI = ({
|
|
|
|
|
onExportToPng={createExporter("png")}
|
|
|
|
|
onExportToSvg={createExporter("svg")}
|
|
|
|
|
onExportToClipboard={createExporter("clipboard")}
|
|
|
|
|
onExportToBackend={(exportedElements) => {
|
|
|
|
|
onExportToBackend={async (exportedElements) => {
|
|
|
|
|
if (canvas) {
|
|
|
|
|
exportCanvas(
|
|
|
|
|
try {
|
|
|
|
|
await exportCanvas(
|
|
|
|
|
"backend",
|
|
|
|
|
exportedElements,
|
|
|
|
|
{
|
|
|
|
@ -343,6 +349,10 @@ const LayerUI = ({
|
|
|
|
|
canvas,
|
|
|
|
|
appState,
|
|
|
|
|
);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error(error);
|
|
|
|
|
setAppState({ errorMessage: error.message });
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
@ -577,7 +587,7 @@ const LayerUI = ({
|
|
|
|
|
)}
|
|
|
|
|
{appState.showShortcutsDialog && (
|
|
|
|
|
<ShortcutsDialog
|
|
|
|
|
onClose={() => setAppState({ showShortcutsDialog: null })}
|
|
|
|
|
onClose={() => setAppState({ showShortcutsDialog: false })}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
{renderFixedSideContainer()}
|
|
|
|
|