Fix package build

This commit is contained in:
Arun Kumar 2021-02-16 20:12:34 +05:30
parent 4d75a2c795
commit 7bf4a0aac1
2 changed files with 11 additions and 10 deletions

View file

@ -283,6 +283,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
unmounted: boolean = false; unmounted: boolean = false;
actionManager: ActionManager; actionManager: ActionManager;
private excalidrawContainerRef = React.createRef<HTMLDivElement>(); private excalidrawContainerRef = React.createRef<HTMLDivElement>();
_isMobile: boolean;
public static defaultProps: Partial<ExcalidrawProps> = { public static defaultProps: Partial<ExcalidrawProps> = {
width: window.innerWidth, width: window.innerWidth,
@ -350,6 +351,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
this.actionManager.registerAction(createUndoAction(history)); this.actionManager.registerAction(createUndoAction(history));
this.actionManager.registerAction(createRedoAction(history)); this.actionManager.registerAction(createRedoAction(history));
this._isMobile = isMobile();
} }
private renderCanvas() { private renderCanvas() {
@ -972,6 +975,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
}, },
{ {
renderOptimizations: true, renderOptimizations: true,
renderScrollbars: !this._isMobile,
}, },
); );
if (scrollBars) { if (scrollBars) {
@ -3693,8 +3697,6 @@ class App extends React.Component<ExcalidrawProps, AppState> {
const separator = "separator"; const separator = "separator";
const _isMobile = isMobile();
const elements = this.scene.getElements(); const elements = this.scene.getElements();
const element = this.getElementAtPosition(x, y); const element = this.getElementAtPosition(x, y);
const options: ContextMenuOption[] = []; const options: ContextMenuOption[] = [];
@ -3730,7 +3732,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
ContextMenu.push({ ContextMenu.push({
options: [ options: [
_isMobile && this._isMobile &&
navigator.clipboard && { navigator.clipboard && {
name: "paste", name: "paste",
perform: (elements, appStates) => { perform: (elements, appStates) => {
@ -3741,7 +3743,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
}, },
contextItemLabel: "labels.paste", contextItemLabel: "labels.paste",
}, },
_isMobile && navigator.clipboard && separator, this._isMobile && navigator.clipboard && separator,
probablySupportsClipboardBlob && probablySupportsClipboardBlob &&
elements.length > 0 && elements.length > 0 &&
actionCopyAsPng, actionCopyAsPng,
@ -3786,9 +3788,9 @@ class App extends React.Component<ExcalidrawProps, AppState> {
ContextMenu.push({ ContextMenu.push({
options: [ options: [
_isMobile && actionCut, this._isMobile && actionCut,
_isMobile && navigator.clipboard && actionCopy, this._isMobile && navigator.clipboard && actionCopy,
_isMobile && this._isMobile &&
navigator.clipboard && { navigator.clipboard && {
name: "paste", name: "paste",
perform: (elements, appStates) => { perform: (elements, appStates) => {
@ -3799,7 +3801,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
}, },
contextItemLabel: "labels.paste", contextItemLabel: "labels.paste",
}, },
_isMobile && separator, this._isMobile && separator,
...options, ...options,
separator, separator,
actionCopyStyles, actionCopyStyles,

View file

@ -49,7 +49,6 @@ import {
} from "../element/transformHandles"; } from "../element/transformHandles";
import { viewportCoordsToSceneCoords, supportsEmoji } from "../utils"; import { viewportCoordsToSceneCoords, supportsEmoji } from "../utils";
import { UserIdleState } from "../excalidraw-app/collab/types"; import { UserIdleState } from "../excalidraw-app/collab/types";
import { isMobile } from "../is-mobile";
const hasEmojiSupport = supportsEmoji(); const hasEmojiSupport = supportsEmoji();
@ -187,7 +186,7 @@ export const renderScene = (
sceneState: SceneState, sceneState: SceneState,
// extra options, currently passed by export helper // extra options, currently passed by export helper
{ {
renderScrollbars = !isMobile(), renderScrollbars = true,
renderSelection = true, renderSelection = true,
// Whether to employ render optimizations to improve performance. // Whether to employ render optimizations to improve performance.
// Should not be turned on for export operations and similar, because it // Should not be turned on for export operations and similar, because it