glitchgrab 1.27.0 → 1.28.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -6,7 +6,8 @@ import {
6
6
  useContext,
7
7
  useRef as useRef3,
8
8
  useEffect as useEffect3,
9
- useCallback
9
+ useCallback,
10
+ useState as useState3
10
11
  } from "react";
11
12
 
12
13
  // src/error-boundary.tsx
@@ -738,6 +739,24 @@ function AnnotationCanvas({ imageSrc, onSave, onCancel }) {
738
739
  );
739
740
  }
740
741
 
742
+ // src/shortcut.ts
743
+ var GLITCHGRAB_SHORTCUT = "Ctrl+Shift+G";
744
+ var GLITCHGRAB_SHORTCUT_MAC = "\u2318\u21E7G";
745
+ function isMac() {
746
+ try {
747
+ if (typeof navigator === "undefined") return false;
748
+ return /Mac|iPhone|iPad|iPod/i.test(navigator.platform || navigator.userAgent);
749
+ } catch (e) {
750
+ return false;
751
+ }
752
+ }
753
+ function getShortcutLabel() {
754
+ return isMac() ? GLITCHGRAB_SHORTCUT_MAC : GLITCHGRAB_SHORTCUT;
755
+ }
756
+ function matchesShortcut(e) {
757
+ return (e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === "g";
758
+ }
759
+
741
760
  // src/report-dialog.tsx
742
761
  import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
743
762
  function useIsDark() {
@@ -1447,6 +1466,24 @@ function ReportDialog({
1447
1466
  },
1448
1467
  children: step === 1 ? "What's on your mind?" : "Tell us more"
1449
1468
  }
1469
+ ),
1470
+ step === 1 && /* @__PURE__ */ jsx2(
1471
+ "span",
1472
+ {
1473
+ title: "Press this anywhere to open Glitchgrab",
1474
+ style: {
1475
+ fontSize: "10px",
1476
+ fontWeight: 600,
1477
+ lineHeight: 1,
1478
+ padding: "3px 6px",
1479
+ borderRadius: "4px",
1480
+ border: `1px solid ${t.inputBorder}`,
1481
+ background: t.inputBg,
1482
+ color: t.textMuted,
1483
+ whiteSpace: "nowrap"
1484
+ },
1485
+ children: getShortcutLabel()
1486
+ }
1450
1487
  )
1451
1488
  ]
1452
1489
  }
@@ -2942,7 +2979,7 @@ function GlitchgrabProviderInner({
2942
2979
  try {
2943
2980
  if (typeof window === "undefined") return;
2944
2981
  const handleKeyDown = (e) => {
2945
- if ((e.metaKey || e.ctrlKey) && e.shiftKey && e.key.toLowerCase() === "g") {
2982
+ if (matchesShortcut(e)) {
2946
2983
  e.preventDefault();
2947
2984
  openReportDialog();
2948
2985
  }
@@ -2952,6 +2989,10 @@ function GlitchgrabProviderInner({
2952
2989
  } catch (e) {
2953
2990
  }
2954
2991
  }, [openReportDialog]);
2992
+ const [shortcutLabel, setShortcutLabel] = useState3(GLITCHGRAB_SHORTCUT);
2993
+ useEffect3(() => {
2994
+ setShortcutLabel(getShortcutLabel());
2995
+ }, []);
2955
2996
  return /* @__PURE__ */ jsxs3(
2956
2997
  GlitchgrabContext.Provider,
2957
2998
  {
@@ -2962,7 +3003,8 @@ function GlitchgrabProviderInner({
2962
3003
  report,
2963
3004
  addBreadcrumb: addBreadcrumb2,
2964
3005
  openReportDialog,
2965
- enhanceText: enhance
3006
+ enhanceText: enhance,
3007
+ shortcutLabel
2966
3008
  },
2967
3009
  children: [
2968
3010
  /* @__PURE__ */ jsx3(
@@ -3193,6 +3235,8 @@ function useGlitchgrabActions({
3193
3235
  };
3194
3236
  }
3195
3237
  export {
3238
+ GLITCHGRAB_SHORTCUT,
3239
+ GLITCHGRAB_SHORTCUT_MAC,
3196
3240
  GlitchgrabErrorBoundary,
3197
3241
  GlitchgrabProvider,
3198
3242
  ReportButton,
@@ -3205,7 +3249,9 @@ export {
3205
3249
  enhanceText,
3206
3250
  fetchGlitchgrabReports,
3207
3251
  getBreadcrumbs,
3252
+ getShortcutLabel,
3208
3253
  initBreadcrumbs,
3254
+ matchesShortcut,
3209
3255
  sanitizeUrl,
3210
3256
  sendReport,
3211
3257
  shouldSkipDuplicate,