Sfoglia il codice sorgente

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

vanilla_orig
Aakansha Doshi 4 anni fa
parent
commit
b5fc8757a4
Nessun account collegato all'indirizzo email del committer
3 ha cambiato i file con 14 aggiunte e 6 eliminazioni
  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 Vedi File

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

+ 6
- 5
src/components/App.tsx Vedi File

@@ -3701,15 +3701,16 @@ class App extends React.Component<ExcalidrawProps, AppState> {
3701 3701
       options.push(actionCopyAsSvg);
3702 3702
     }
3703 3703
     if (!element) {
3704
-      const viewModeOptions: ContextMenuOption[] = [
3704
+      const viewModeOptions = [
3705 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 3711
         actionToggleStats,
3707 3712
       ];
3708 3713
 
3709
-      if (typeof this.props.viewModeEnabled === "undefined") {
3710
-        viewModeOptions.push(actionToggleViewMode);
3711
-      }
3712
-
3713 3714
       ContextMenu.push({
3714 3715
         options: viewModeOptions,
3715 3716
         top: clientY,

+ 6
- 0
src/constants.ts Vedi File

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

Loading…
Annulla
Salva