Browse Source

Keep errors, elements and comments consistent (#2340)

Co-authored-by: David Luzar <luzar.david@gmail.com>
vanilla_orig
Lipis 4 years ago
parent
commit
5d295415db
No account linked to committer's email address

+ 1
- 1
.lintstagedrc.js View File

@@ -1,7 +1,7 @@
1 1
 const { CLIEngine } = require("eslint");
2 2
 
3 3
 // see https://github.com/okonet/lint-staged#how-can-i-ignore-files-from-eslintignore-
4
-//  for explanation
4
+// for explanation
5 5
 const cli = new CLIEngine({});
6 6
 
7 7
 module.exports = {

+ 1
- 1
src/actions/actionProperties.tsx View File

@@ -540,7 +540,7 @@ export const actionChangeSharpness = register({
540 540
       appState,
541 541
     );
542 542
     const shouldUpdateForNonLinearElements = targetElements.length
543
-      ? targetElements.every((e) => !isLinearElement(e))
543
+      ? targetElements.every((el) => !isLinearElement(el))
544 544
       : !isLinearElementType(appState.elementType);
545 545
     const shouldUpdateForLinearElements = targetElements.length
546 546
       ? targetElements.every(isLinearElement)

+ 7
- 7
src/clipboard.ts View File

@@ -57,9 +57,9 @@ export const copyToClipboard = async (
57 57
   try {
58 58
     PREFER_APP_CLIPBOARD = false;
59 59
     await copyTextToSystemClipboard(json);
60
-  } catch (err) {
60
+  } catch (error) {
61 61
     PREFER_APP_CLIPBOARD = true;
62
-    console.error(err);
62
+    console.error(error);
63 63
   }
64 64
 };
65 65
 
@@ -128,7 +128,7 @@ export const parseClipboard = async (
128 128
   }
129 129
 
130 130
   // if system clipboard contains spreadsheet, use it even though it's
131
-  //  technically possible it's staler than in-app clipboard
131
+  // technically possible it's staler than in-app clipboard
132 132
   const spreadsheetResult = parsePotentialSpreadsheet(systemClipboard);
133 133
   if (spreadsheetResult) {
134 134
     return spreadsheetResult;
@@ -150,8 +150,8 @@ export const parseClipboard = async (
150 150
     return appClipboardData;
151 151
   } catch {
152 152
     // system clipboard doesn't contain excalidraw elements → return plaintext
153
-    //  unless we set a flag to prefer in-app clipboard because browser didn't
154
-    //  support storing to system clipboard on copy
153
+    // unless we set a flag to prefer in-app clipboard because browser didn't
154
+    // support storing to system clipboard on copy
155 155
     return PREFER_APP_CLIPBOARD && appClipboardData.elements
156 156
       ? appClipboardData
157 157
       : { text: systemClipboard };
@@ -170,7 +170,7 @@ export const copyTextToSystemClipboard = async (text: string | null) => {
170 170
   if (probablySupportsClipboardWriteText) {
171 171
     try {
172 172
       // NOTE: doesn't work on FF on non-HTTPS domains, or when document
173
-      //  not focused
173
+      // not focused
174 174
       await navigator.clipboard.writeText(text || "");
175 175
       copied = true;
176 176
     } catch (error) {
@@ -179,7 +179,7 @@ export const copyTextToSystemClipboard = async (text: string | null) => {
179 179
   }
180 180
 
181 181
   // Note that execCommand doesn't allow copying empty strings, so if we're
182
-  //  clearing clipboard using this API, we must copy at least an empty char
182
+  // clearing clipboard using this API, we must copy at least an empty char
183 183
   if (!copied && !copyTextViaExecCommand(text || " ")) {
184 184
     throw new Error("couldn't copy");
185 185
   }

+ 32
- 32
src/components/App.tsx View File

@@ -523,7 +523,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
523 523
           collabForceLoadFlag,
524 524
         );
525 525
         // if loading same room as the one previously unloaded within 15sec
526
-        //  force reload without prompting
526
+        // force reload without prompting
527 527
         if (previousRoom === roomID && Date.now() - timestamp < 15000) {
528 528
           return true;
529 529
         }
@@ -561,8 +561,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
561 561
     history.clear();
562 562
   };
563 563
 
564
-  /** Completely resets scene & history.
565
-   * Do not use for clear scene user action. */
564
+  // Completely resets scene & history.
565
+  // Do not use for clear scene user action.
566 566
   private resetScene = withBatchedUpdates(() => {
567 567
     this.scene.replaceAllElements([]);
568 568
     this.setState({
@@ -654,7 +654,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
654 654
 
655 655
     if (isCollaborationScene) {
656 656
       // when joining a room we don't want user's local scene data to be merged
657
-      //  into the remote scene
657
+      // into the remote scene
658 658
       this.resetScene();
659 659
 
660 660
       this.initializeSocketClient({ showLoadingState: true });
@@ -847,7 +847,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
847 847
       !isSavedToFirebase(this.portal, syncableElements)
848 848
     ) {
849 849
       // this won't run in time if user decides to leave the site, but
850
-      //  the purpose is to run in immediately after user decides to stay
850
+      // the purpose is to run in immediately after user decides to stay
851 851
       this.saveCollabRoomToFirebase(syncableElements);
852 852
 
853 853
       event.preventDefault();
@@ -943,7 +943,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
943 943
     const { atLeastOneVisibleElement, scrollBars } = renderScene(
944 944
       elements.filter((element) => {
945 945
         // don't render text element that's being currently edited (it's
946
-        //  rendered on remote only)
946
+        // rendered on remote only)
947 947
         return (
948 948
           !this.state.editingElement ||
949 949
           this.state.editingElement.type !== "text" ||
@@ -1108,7 +1108,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
1108 1108
       const elementUnderCursor = document.elementFromPoint(cursorX, cursorY);
1109 1109
       if (
1110 1110
         // if no ClipboardEvent supplied, assume we're pasting via contextMenu
1111
-        //  thus these checks don't make sense
1111
+        // thus these checks don't make sense
1112 1112
         event &&
1113 1113
         (!(elementUnderCursor instanceof HTMLCanvasElement) ||
1114 1114
           isWritableElement(target))
@@ -1380,7 +1380,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
1380 1380
       const roomKey = roomMatch[2];
1381 1381
 
1382 1382
       // fallback in case you're not alone in the room but still don't receive
1383
-      //  initial SCENE_UPDATE message
1383
+      // initial SCENE_UPDATE message
1384 1384
       this.socketInitializationTimer = setTimeout(
1385 1385
         this.initializeSocket,
1386 1386
         INITIAL_SCENE_UPDATE_TIMEOUT,
@@ -1432,7 +1432,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
1432 1432
                 decryptedData.payload.socketID;
1433 1433
 
1434 1434
               // NOTE purposefully mutating collaborators map in case of
1435
-              //  pointer updates so as not to trigger LayerUI rerender
1435
+              // pointer updates so as not to trigger LayerUI rerender
1436 1436
               this.setState((state) => {
1437 1437
                 if (!state.collaborators.has(socketId)) {
1438 1438
                   state.collaborators.set(socketId, {});
@@ -1467,9 +1467,9 @@ class App extends React.Component<ExcalidrawProps, AppState> {
1467 1467
         if (elements) {
1468 1468
           this.handleRemoteSceneUpdate(elements, { initFromSnapshot: true });
1469 1469
         }
1470
-      } catch (e) {
1470
+      } catch (error) {
1471 1471
         // log the error and move on. other peers will sync us the scene.
1472
-        console.error(e);
1472
+        console.error(error);
1473 1473
       }
1474 1474
     }
1475 1475
   };
@@ -1814,7 +1814,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
1814 1814
     });
1815 1815
 
1816 1816
     // do an initial update to re-initialize element position since we were
1817
-    //  modifying element's x/y for sake of editor (case: syncing to remote)
1817
+    // modifying element's x/y for sake of editor (case: syncing to remote)
1818 1818
     updateElement(element.text);
1819 1819
   }
1820 1820
 
@@ -1920,7 +1920,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
1920 1920
 
1921 1921
     if (existingTextElement) {
1922 1922
       // if text element is no longer centered to a container, reset
1923
-      //  verticalAlign to default because it's currently internal-only
1923
+      // verticalAlign to default because it's currently internal-only
1924 1924
       if (!parentCenterPosition || element.textAlign !== "center") {
1925 1925
         mutateElement(element, { verticalAlign: DEFAULT_VERTICAL_ALIGN });
1926 1926
       }
@@ -1931,7 +1931,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
1931 1931
       ]);
1932 1932
 
1933 1933
       // case: creating new text not centered to parent elemenent → offset Y
1934
-      //  so that the text is centered to cursor position
1934
+      // so that the text is centered to cursor position
1935 1935
       if (!parentCenterPosition) {
1936 1936
         mutateElement(element, {
1937 1937
           y: element.y - element.baseline / 2,
@@ -1952,7 +1952,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
1952 1952
     event: React.MouseEvent<HTMLCanvasElement>,
1953 1953
   ) => {
1954 1954
     // case: double-clicking with arrow/line tool selected would both create
1955
-    //  text and enter multiElement mode
1955
+    // text and enter multiElement mode
1956 1956
     if (this.state.multiElement) {
1957 1957
       return;
1958 1958
     }
@@ -2129,7 +2129,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
2129 2129
 
2130 2130
       if (lastPoint === lastCommittedPoint) {
2131 2131
         // if we haven't yet created a temp point and we're beyond commit-zone
2132
-        //  threshold, add a point
2132
+        // threshold, add a point
2133 2133
         if (
2134 2134
           distance2d(
2135 2135
             scenePointerX - rx,
@@ -2144,11 +2144,11 @@ class App extends React.Component<ExcalidrawProps, AppState> {
2144 2144
         } else {
2145 2145
           document.documentElement.style.cursor = CURSOR_TYPE.POINTER;
2146 2146
           // in this branch, we're inside the commit zone, and no uncommitted
2147
-          //  point exists. Thus do nothing (don't add/remove points).
2147
+          // point exists. Thus do nothing (don't add/remove points).
2148 2148
         }
2149 2149
       } else {
2150 2150
         // cursor moved inside commit zone, and there's uncommitted point,
2151
-        //  thus remove it
2151
+        // thus remove it
2152 2152
         if (
2153 2153
           points.length > 2 &&
2154 2154
           lastCommittedPoint &&
@@ -2293,8 +2293,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
2293 2293
     // fixes pointermove causing selection of UI texts #32
2294 2294
     event.preventDefault();
2295 2295
     // Preventing the event above disables default behavior
2296
-    //  of defocusing potentially focused element, which is what we
2297
-    //  want when clicking inside the canvas.
2296
+    // of defocusing potentially focused element, which is what we
2297
+    // want when clicking inside the canvas.
2298 2298
     if (document.activeElement instanceof HTMLElement) {
2299 2299
       document.activeElement.blur();
2300 2300
     }
@@ -2739,8 +2739,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
2739 2739
             }
2740 2740
 
2741 2741
             // Add hit element to selection. At this point if we're not holding
2742
-            //  SHIFT the previously selected element(s) were deselected above
2743
-            //  (make sure you use setState updater to use latest state)
2742
+            // SHIFT the previously selected element(s) were deselected above
2743
+            // (make sure you use setState updater to use latest state)
2744 2744
             if (
2745 2745
               !someHitElementIsSelected &&
2746 2746
               !pointerDownState.hit.hasHitCommonBoundingBoxOfSelectedElements
@@ -2798,8 +2798,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
2798 2798
     pointerDownState: PointerDownState,
2799 2799
   ): void => {
2800 2800
     // if we're currently still editing text, clicking outside
2801
-    //  should only finalize it, not create another (irrespective
2802
-    //  of state.elementLocked)
2801
+    // should only finalize it, not create another (irrespective
2802
+    // of state.elementLocked)
2803 2803
     if (this.state.editingElement?.type === "text") {
2804 2804
       return;
2805 2805
     }
@@ -2860,7 +2860,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
2860 2860
         },
2861 2861
       }));
2862 2862
       // clicking outside commit zone → update reference for last committed
2863
-      //  point
2863
+      // point
2864 2864
       mutateElement(multiElement, {
2865 2865
         lastCommittedPoint: multiElement.points[multiElement.points.length - 1],
2866 2866
       });
@@ -2986,9 +2986,9 @@ class App extends React.Component<ExcalidrawProps, AppState> {
2986 2986
       );
2987 2987
 
2988 2988
       // for arrows/lines, don't start dragging until a given threshold
2989
-      //  to ensure we don't create a 2-point arrow by mistake when
2990
-      //  user clicks mouse in a way that it moves a tiny bit (thus
2991
-      //  triggering pointermove)
2989
+      // to ensure we don't create a 2-point arrow by mistake when
2990
+      // user clicks mouse in a way that it moves a tiny bit (thus
2991
+      // triggering pointermove)
2992 2992
       if (
2993 2993
         !pointerDownState.drag.hasOccurred &&
2994 2994
         (this.state.elementType === "arrow" ||
@@ -3127,7 +3127,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
3127 3127
               if (
3128 3128
                 this.state.selectedElementIds[element.id] ||
3129 3129
                 // case: the state.selectedElementIds might not have been
3130
-                //  updated yet by the time this mousemove event is fired
3130
+                // updated yet by the time this mousemove event is fired
3131 3131
                 (element.id === hitElement?.id &&
3132 3132
                   pointerDownState.hit.wasAddedToSelection)
3133 3133
               ) {
@@ -3331,7 +3331,7 @@ class App extends React.Component<ExcalidrawProps, AppState> {
3331 3331
         selectionElement: null,
3332 3332
         cursorButton: "up",
3333 3333
         // text elements are reset on finalize, and resetting on pointerup
3334
-        //  may cause issues with double taps
3334
+        // may cause issues with double taps
3335 3335
         editingElement:
3336 3336
           multiElement || isTextElement(this.state.editingElement)
3337 3337
             ? this.state.editingElement
@@ -3481,8 +3481,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
3481 3481
           if (this.state.selectedElementIds[hitElement.id]) {
3482 3482
             if (isSelectedViaGroup(this.state, hitElement)) {
3483 3483
               // We want to unselect all groups hitElement is part of
3484
-              //  as well as all elements that are part of the groups
3485
-              //  hitElement is part of
3484
+              // as well as all elements that are part of the groups
3485
+              // hitElement is part of
3486 3486
               const idsOfSelectedElementsThatAreInGroups = hitElement.groupIds
3487 3487
                 .flatMap((groupId) =>
3488 3488
                   getElementsInGroup(this.scene.getElements(), groupId),

+ 1
- 2
src/components/Portal.tsx View File

@@ -167,8 +167,7 @@ class Portal {
167 167
     const newElements = sceneElements
168 168
       .reduce((elements, element) => {
169 169
         // if the remote element references one that's currently
170
-        //  edited on local, skip it (it'll be added in the next
171
-        //  step)
170
+        // edited on local, skip it (it'll be added in the next step)
172 171
         if (
173 172
           element.id === this.app.state.editingElement?.id ||
174 173
           element.id === this.app.state.resizingElement?.id ||

+ 2
- 1
src/data/blob.ts View File

@@ -108,7 +108,8 @@ export const loadFromBlob = async (
108 108
       },
109 109
       localAppState,
110 110
     );
111
-  } catch {
111
+  } catch (error) {
112
+    console.error(error.message);
112 113
     throw new Error(t("alerts.couldNotLoadInvalidFile"));
113 114
   }
114 115
 };

+ 2
- 2
src/data/firebase.ts View File

@@ -86,7 +86,7 @@ export const isSavedToFirebase = (
86 86
     return firebaseSceneVersionCache.get(portal.socket) === sceneVersion;
87 87
   }
88 88
   // if no room exists, consider the room saved so that we don't unnecessarily
89
-  //  prevent unload (there's nothing we could do at that point anyway)
89
+  // prevent unload (there's nothing we could do at that point anyway)
90 90
   return true;
91 91
 };
92 92
 
@@ -97,7 +97,7 @@ export async function saveToFirebase(
97 97
   const { roomID, roomKey, socket } = portal;
98 98
   if (
99 99
     // if no room exists, consider the room saved because there's nothing we can
100
-    //  do at this point
100
+    // do at this point
101 101
     !roomID ||
102 102
     !roomKey ||
103 103
     !socket ||

+ 6
- 6
src/data/library.ts View File

@@ -31,7 +31,7 @@ export class Library {
31 31
         }
32 32
 
33 33
         // detect z-index difference by checking the excalidraw elements
34
-        //  are in order
34
+        // are in order
35 35
         return libraryItem.every((libItemExcalidrawItem, idx) => {
36 36
           return (
37 37
             libItemExcalidrawItem.id === targetLibraryItem[idx].id &&
@@ -69,8 +69,8 @@ export class Library {
69 69
         Library.libraryCache = JSON.parse(JSON.stringify(items));
70 70
 
71 71
         resolve(items);
72
-      } catch (e) {
73
-        console.error(e);
72
+      } catch (error) {
73
+        console.error(error);
74 74
         resolve([]);
75 75
       }
76 76
     });
@@ -81,12 +81,12 @@ export class Library {
81 81
     try {
82 82
       const serializedItems = JSON.stringify(items);
83 83
       // cache optimistically so that consumers have access to the latest
84
-      //  immediately
84
+      // immediately
85 85
       Library.libraryCache = JSON.parse(serializedItems);
86 86
       localStorage.setItem(STORAGE_KEYS.LOCAL_STORAGE_LIBRARY, serializedItems);
87
-    } catch (e) {
87
+    } catch (error) {
88 88
       Library.libraryCache = prevLibraryItems;
89
-      console.error(e);
89
+      console.error(error);
90 90
     }
91 91
   };
92 92
 }

+ 6
- 6
src/data/restore.ts View File

@@ -32,7 +32,7 @@ const restoreElementWithProperties = <T extends ExcalidrawElement>(
32 32
   const base: Pick<T, keyof ExcalidrawElement> = {
33 33
     type: element.type,
34 34
     // all elements must have version > 0 so getSceneVersion() will pick up
35
-    //  newly added elements
35
+    // newly added elements
36 36
     version: element.version || 1,
37 37
     versionNonce: element.versionNonce ?? 0,
38 38
     isDeleted: element.isDeleted ?? false,
@@ -112,9 +112,9 @@ const restoreElement = (
112 112
     case "diamond":
113 113
       return restoreElementWithProperties(element, {});
114 114
 
115
-    // don't use default case so as to catch a missing an element type case
116
-    //  (we also don't want to throw, but instead return void so we
117
-    //   filter out these unsupported elements from the restored array)
115
+    // Don't use default case so as to catch a missing an element type case.
116
+    // We also don't want to throw, but instead return void so we filter
117
+    // out these unsupported elements from the restored array.
118 118
   }
119 119
 };
120 120
 
@@ -123,7 +123,7 @@ export const restoreElements = (
123 123
 ): ExcalidrawElement[] => {
124 124
   return (elements || []).reduce((elements, element) => {
125 125
     // filtering out selection, which is legacy, no longer kept in elements,
126
-    //  and causing issues if retained
126
+    // and causing issues if retained
127 127
     if (element.type !== "selection" && !isInvisiblySmallElement(element)) {
128 128
       const migratedElement = restoreElement(element);
129 129
       if (migratedElement) {
@@ -161,7 +161,7 @@ const restoreAppState = (
161 161
     ...nextAppState,
162 162
     offsetLeft: appState.offsetLeft || 0,
163 163
     offsetTop: appState.offsetTop || 0,
164
-    /* Migrates from previous version where appState.zoom was a number */
164
+    // Migrates from previous version where appState.zoom was a number
165 165
     zoom:
166 166
       typeof appState.zoom === "number"
167 167
         ? {

+ 8
- 8
src/element/linearElementEditor.ts View File

@@ -227,7 +227,7 @@ export class LinearElementEditor {
227 227
     );
228 228
 
229 229
     // if we clicked on a point, set the element as hitElement otherwise
230
-    //  it would get deselected if the point is outside the hitbox area
230
+    // it would get deselected if the point is outside the hitbox area
231 231
     if (clickedPointIndex > -1) {
232 232
       ret.hitElement = element;
233 233
     } else {
@@ -379,8 +379,8 @@ export class LinearElementEditor {
379 379
     const pointHandles = this.getPointsGlobalCoordinates(element);
380 380
     let idx = pointHandles.length;
381 381
     // loop from right to left because points on the right are rendered over
382
-    //  points on the left, thus should take precedence when clicking, if they
383
-    //  overlap
382
+    // points on the left, thus should take precedence when clicking, if they
383
+    // overlap
384 384
     while (--idx > -1) {
385 385
       const point = pointHandles[idx];
386 386
       if (
@@ -458,10 +458,10 @@ export class LinearElementEditor {
458 458
     const { points } = element;
459 459
 
460 460
     // in case we're moving start point, instead of modifying its position
461
-    //  which would break the invariant of it being at [0,0], we move
462
-    //  all the other points in the opposite direction by delta to
463
-    //  offset it. We do the same with actual element.x/y position, so
464
-    //  this hacks are completely transparent to the user.
461
+    // which would break the invariant of it being at [0,0], we move
462
+    // all the other points in the opposite direction by delta to
463
+    // offset it. We do the same with actual element.x/y position, so
464
+    // this hacks are completely transparent to the user.
465 465
     let offsetX = 0;
466 466
     let offsetY = 0;
467 467
 
@@ -475,7 +475,7 @@ export class LinearElementEditor {
475 475
       nextPoints.splice(pointIndex, 1);
476 476
       if (pointIndex === 0) {
477 477
         // if deleting first point, make the next to be [0,0] and recalculate
478
-        //  positions of the rest with respect to it
478
+        // positions of the rest with respect to it
479 479
         offsetX = nextPoints[0][0];
480 480
         offsetY = nextPoints[0][1];
481 481
         nextPoints = nextPoints.map((point, idx) => {

+ 1
- 1
src/element/newElement.ts View File

@@ -225,7 +225,7 @@ export const newLinearElement = (
225 225
 };
226 226
 
227 227
 // Simplified deep clone for the purpose of cloning ExcalidrawElement only
228
-//  (doesn't clone Date, RegExp, Map, Set, Typed arrays etc.)
228
+// (doesn't clone Date, RegExp, Map, Set, Typed arrays etc.)
229 229
 //
230 230
 // Adapted from https://github.com/lukeed/klona
231 231
 export const deepCopyElement = (val: any, depth: number = 0) => {

+ 4
- 4
src/element/textWysiwyg.tsx View File

@@ -25,7 +25,7 @@ const getTransform = (
25 25
   const { zoom, offsetTop, offsetLeft } = appState;
26 26
   const degree = (180 * angle) / Math.PI;
27 27
   // offsets must be multiplied by 2 to account for the division by 2 of
28
-  //  the whole expression afterwards
28
+  // the whole expression afterwards
29 29
   return `translate(${((width - offsetLeft * 2) * (zoom.value - 1)) / 2}px, ${
30 30
     ((height - offsetTop * 2) * (zoom.value - 1)) / 2
31 31
   }px) scale(${zoom.value}) rotate(${degree}deg)`;
@@ -166,7 +166,7 @@ export const textWysiwyg = ({
166 166
   const rebindBlur = () => {
167 167
     window.removeEventListener("pointerup", rebindBlur);
168 168
     // deferred to guard against focus traps on various UIs that steal focus
169
-    //  upon pointerUp
169
+    // upon pointerUp
170 170
     setTimeout(() => {
171 171
       editable.onblur = handleSubmit;
172 172
       // case: clicking on the same property → no change → no update → no focus
@@ -184,7 +184,7 @@ export const textWysiwyg = ({
184 184
       editable.onblur = null;
185 185
       window.addEventListener("pointerup", rebindBlur);
186 186
       // handle edge-case where pointerup doesn't fire e.g. due to user
187
-      //  alt-tabbing away
187
+      // alt-tabbing away
188 188
       window.addEventListener("blur", handleSubmit);
189 189
     }
190 190
   };
@@ -199,7 +199,7 @@ export const textWysiwyg = ({
199 199
 
200 200
   editable.onblur = handleSubmit;
201 201
   // reposition wysiwyg in case of window resize. Happens on mobile when
202
-  //  device keyboard is opened.
202
+  // device keyboard is opened.
203 203
   window.addEventListener("resize", updateWysiwygStyle);
204 204
   window.addEventListener("pointerdown", onPointerDown);
205 205
   window.addEventListener("wheel", stopEvent, {

+ 5
- 5
src/renderer/renderElement.ts View File

@@ -126,7 +126,7 @@ const drawElementOnCanvas = (
126 126
         const shouldTemporarilyAttach = rtl && !context.canvas.isConnected;
127 127
         if (shouldTemporarilyAttach) {
128 128
           // to correctly render RTL text mixed with LTR, we have to append it
129
-          //  to the DOM
129
+          // to the DOM
130 130
           document.body.appendChild(context.canvas);
131 131
         }
132 132
         context.canvas.setAttribute("dir", rtl ? "rtl" : "ltr");
@@ -194,17 +194,17 @@ export const generateRoughOptions = (element: ExcalidrawElement): Options => {
194 194
         ? DASHARRAY_DOTTED
195 195
         : undefined,
196 196
     // for non-solid strokes, disable multiStroke because it tends to make
197
-    //  dashes/dots overlay each other
197
+    // dashes/dots overlay each other
198 198
     disableMultiStroke: element.strokeStyle !== "solid",
199 199
     // for non-solid strokes, increase the width a bit to make it visually
200
-    //  similar to solid strokes, because we're also disabling multiStroke
200
+    // similar to solid strokes, because we're also disabling multiStroke
201 201
     strokeWidth:
202 202
       element.strokeStyle !== "solid"
203 203
         ? element.strokeWidth + 0.5
204 204
         : element.strokeWidth,
205 205
     // when increasing strokeWidth, we must explicitly set fillWeight and
206
-    //  hachureGap because if not specified, roughjs uses strokeWidth to
207
-    //  calculate them (and we don't want the fills to be modified)
206
+    // hachureGap because if not specified, roughjs uses strokeWidth to
207
+    // calculate them (and we don't want the fills to be modified)
208 208
     fillWeight: element.strokeWidth / 2,
209 209
     hachureGap: element.strokeWidth * 4,
210 210
     roughness: element.roughness,

+ 1
- 1
src/renderer/renderScene.ts View File

@@ -187,7 +187,7 @@ export const renderScene = (
187 187
     renderSelection = true,
188 188
     // Whether to employ render optimizations to improve performance.
189 189
     // Should not be turned on for export operations and similar, because it
190
-    //  doesn't guarantee pixel-perfect output.
190
+    // doesn't guarantee pixel-perfect output.
191 191
     renderOptimizations = false,
192 192
     renderGrid = true,
193 193
   }: {

+ 1
- 1
src/scene/Scene.ts View File

@@ -129,7 +129,7 @@ class Scene {
129 129
       }
130 130
     });
131 131
     // done not for memory leaks, but to guard against possible late fires
132
-    //  (I guess?)
132
+    // (I guess?)
133 133
     this.callbacks.clear();
134 134
   }
135 135
 }

+ 9
- 9
src/serviceWorker.tsx View File

@@ -75,10 +75,9 @@ const registerValidSW = (swUrl: string, config?: Config) => {
75 75
               // but the previous service worker will still serve the older
76 76
               // content until all client tabs are closed.
77 77
 
78
-              // console.log(
79
-              //   "New content is available and will be used when all " +
80
-              //     "tabs for this page are closed.",
81
-              // );
78
+              console.info(
79
+                "New content is available and will be used when all tabs for this page are closed.",
80
+              );
82 81
 
83 82
               // Execute callback
84 83
               if (config && config.onUpdate) {
@@ -89,7 +88,7 @@ const registerValidSW = (swUrl: string, config?: Config) => {
89 88
               // It's the perfect time to display a
90 89
               // "Content is cached for offline use." message.
91 90
 
92
-              // console.log("Content is cached for offline use.");
91
+              console.info("Content is cached for offline use.");
93 92
 
94 93
               // Execute callback
95 94
               if (config && config.onSuccess) {
@@ -128,10 +127,11 @@ const checkValidServiceWorker = (swUrl: string, config?: Config) => {
128 127
         registerValidSW(swUrl, config);
129 128
       }
130 129
     })
131
-    .catch(() => {
132
-      // console.log(
133
-      //   "No internet connection found. App is running in offline mode.",
134
-      // );
130
+    .catch((error) => {
131
+      console.info(
132
+        "No internet connection found. App is running in offline mode.",
133
+        error.message,
134
+      );
135 135
     });
136 136
 };
137 137
 

+ 1
- 1
src/tests/binding.test.tsx View File

@@ -68,7 +68,7 @@ describe("element binding", () => {
68 68
       expect(API.getSelectedElement().type).toBe("arrow");
69 69
 
70 70
       // NOTE this mouse down/up + await needs to be done in order to repro
71
-      //  the issue, due to https://github.com/excalidraw/excalidraw/blob/46bff3daceb602accf60c40a84610797260fca94/src/components/App.tsx#L740
71
+      // the issue, due to https://github.com/excalidraw/excalidraw/blob/46bff3daceb602accf60c40a84610797260fca94/src/components/App.tsx#L740
72 72
       mouse.reset();
73 73
       expect(h.state.editingLinearElement).not.toBe(null);
74 74
       mouse.down(0, 0);

+ 1
- 1
src/tests/export.test.tsx View File

@@ -19,7 +19,7 @@ const testElements = [
19 19
       text: "😀",
20 20
     }),
21 21
     // can't get jsdom text measurement to work so this is a temp hack
22
-    //  to ensure the element isn't stripped as invisible
22
+    // to ensure the element isn't stripped as invisible
23 23
     width: 16,
24 24
     height: 16,
25 25
   },

+ 3
- 5
src/tests/regressionTests.test.tsx View File

@@ -1569,7 +1569,7 @@ it(
1569 1569
     expect(API.getSelectedElements().length).toBe(3);
1570 1570
 
1571 1571
     // clicking on first rectangle that is part of the group should select
1572
-    //  that group (exclusively)
1572
+    // that group (exclusively)
1573 1573
     mouse.clickOn(rect1);
1574 1574
     expect(API.getSelectedElements().length).toBe(2);
1575 1575
     expect(Object.keys(h.state.selectedGroupIds).length).toBe(1);
@@ -1594,8 +1594,7 @@ it(
1594 1594
     mouse.up(100, 100);
1595 1595
 
1596 1596
     // Select first rectangle while keeping third one selected.
1597
-    // Third rectangle is selected because it was the last element
1598
-    //  to be created.
1597
+    // Third rectangle is selected because it was the last element to be created.
1599 1598
     mouse.reset();
1600 1599
     Keyboard.withModifierKeys({ shift: true }, () => {
1601 1600
       mouse.click();
@@ -1616,8 +1615,7 @@ it(
1616 1615
     });
1617 1616
     expect(API.getSelectedElements().length).toBe(3);
1618 1617
 
1619
-    // pointer down o first rectangle that is
1620
-    // part of the group
1618
+    // Pointer down o first rectangle that is part of the group
1621 1619
     mouse.reset();
1622 1620
     Keyboard.withModifierKeys({ shift: true }, () => {
1623 1621
       mouse.down();

+ 1
- 1
src/types.ts View File

@@ -41,7 +41,7 @@ export type AppState = {
41 41
   startBoundElement: NonDeleted<ExcalidrawBindableElement> | null;
42 42
   suggestedBindings: SuggestedBinding[];
43 43
   // element being edited, but not necessarily added to elements array yet
44
-  //  (e.g. text element when typing into the input)
44
+  // (e.g. text element when typing into the input)
45 45
   editingElement: NonDeletedExcalidrawElement | null;
46 46
   editingLinearElement: LinearElementEditor | null;
47 47
   elementType: typeof SHAPES[number]["value"];

+ 1
- 1
src/utils.ts View File

@@ -94,7 +94,7 @@ export const measureText = (text: string, font: FontString) => {
94 94
   line.innerText = text
95 95
     .split("\n")
96 96
     // replace empty lines with single space because leading/trailing empty
97
-    //  lines would be stripped from computation
97
+    // lines would be stripped from computation
98 98
     .map((x) => x || " ")
99 99
     .join("\n");
100 100
   const width = line.offsetWidth;

+ 2
- 2
src/zindex.ts View File

@@ -62,7 +62,7 @@ const getTargetIndex = (
62 62
       return false;
63 63
     }
64 64
     // if we're editing group, find closest sibling irrespective of whether
65
-    //  there's a different-group element between them (for legacy reasons)
65
+    // there's a different-group element between them (for legacy reasons)
66 66
     if (appState.editingGroupId) {
67 67
       return element.groupIds.includes(appState.editingGroupId);
68 68
     }
@@ -106,7 +106,7 @@ const getTargetIndex = (
106 106
 
107 107
   if (elementsInSiblingGroup.length) {
108 108
     // assumes getElementsInGroup() returned elements are sorted
109
-    //  by zIndex (ascending)
109
+    // by zIndex (ascending)
110 110
     return direction === "left"
111 111
       ? elements.indexOf(elementsInSiblingGroup[0])
112 112
       : elements.indexOf(

Loading…
Cancel
Save