Bladeren bron

fix: allow to toggle between modes when view only mode to make UI consistent (#3009)

vanilla_orig
Aakansha Doshi 4 jaren geleden
bovenliggende
commit
b5fc8757a4
No account linked to committer's email address
3 gewijzigde bestanden met toevoegingen van 14 en 6 verwijderingen
  1. 2
    1
      src/actions/manager.tsx
  2. 6
    5
      src/components/App.tsx
  3. 6
    0
      src/constants.ts

+ 2
- 1
src/actions/manager.tsx Bestand weergeven

8
 } from "./types";
8
 } from "./types";
9
 import { ExcalidrawElement } from "../element/types";
9
 import { ExcalidrawElement } from "../element/types";
10
 import { AppState, ExcalidrawProps } from "../types";
10
 import { AppState, ExcalidrawProps } from "../types";
11
+import { MODES } from "../constants";
11
 
12
 
12
 // This is the <App> component, but for now we don't care about anything but its
13
 // This is the <App> component, but for now we don't care about anything but its
13
 // `canvas` state.
14
 // `canvas` state.
68
     }
69
     }
69
     const { viewModeEnabled } = this.getAppState();
70
     const { viewModeEnabled } = this.getAppState();
70
     if (viewModeEnabled) {
71
     if (viewModeEnabled) {
71
-      if (data[0].name !== "viewMode") {
72
+      if (!Object.values(MODES).includes(data[0].name)) {
72
         return false;
73
         return false;
73
       }
74
       }
74
     }
75
     }

+ 6
- 5
src/components/App.tsx Bestand weergeven

3701
       options.push(actionCopyAsSvg);
3701
       options.push(actionCopyAsSvg);
3702
     }
3702
     }
3703
     if (!element) {
3703
     if (!element) {
3704
-      const viewModeOptions: ContextMenuOption[] = [
3704
+      const viewModeOptions = [
3705
         ...options,
3705
         ...options,
3706
+        typeof this.props.gridModeEnabled === "undefined" &&
3707
+          actionToggleGridMode,
3708
+        typeof this.props.zenModeEnabled === "undefined" && actionToggleZenMode,
3709
+        typeof this.props.viewModeEnabled === "undefined" &&
3710
+          actionToggleViewMode,
3706
         actionToggleStats,
3711
         actionToggleStats,
3707
       ];
3712
       ];
3708
 
3713
 
3709
-      if (typeof this.props.viewModeEnabled === "undefined") {
3710
-        viewModeOptions.push(actionToggleViewMode);
3711
-      }
3712
-
3713
       ContextMenu.push({
3714
       ContextMenu.push({
3714
         options: viewModeOptions,
3715
         options: viewModeOptions,
3715
         top: clientY,
3716
         top: clientY,

+ 6
- 0
src/constants.ts Bestand weergeven

99
 export const IDLE_THRESHOLD = 60_000;
99
 export const IDLE_THRESHOLD = 60_000;
100
 // Report a user active each ACTIVE_THRESHOLD milliseconds
100
 // Report a user active each ACTIVE_THRESHOLD milliseconds
101
 export const ACTIVE_THRESHOLD = 3_000;
101
 export const ACTIVE_THRESHOLD = 3_000;
102
+
103
+export const MODES = {
104
+  VIEW: "viewMode",
105
+  ZEN: "zenMode",
106
+  GRID: "gridMode",
107
+};

Laden…
Annuleren
Opslaan